Bom dia a todos!
Estou com a seguinte duvida:
Quando faço a pesquisa:
select new Bot(b.identity,b.action,b.closeCase,b.comments,b.name,b.reason) from Bot b
É carregado normal todos os objetos, uso isso em um findAll.
Minha duvida:
meu objeto tem uma chave estrangeira. Como Faço para carregar esse objeto em minha pesquisa? No caso uma lista de objetos “Sector”
minha classe:
@Entity
@Table(name="bot")
public class Bot implements br.com.conrado.j4b.domain.Entity {
private static final long serialVersionUID = -5884531099677067326L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long identity;
@NotNull
@Column(length=45, nullable=false, unique=false)
private String name;
private String closeCase;
@NotNull
@Column
private String action;
@NotNull
@Column(length=10, nullable=false, unique=false)
private String reason;
@NotNull
@Column(length=20, nullable=false, unique=false)
private String comments;
@OneToMany(mappedBy="bot",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
private Set<Sector> sectors = new HashSet<Sector>();
public Bot() {}
public Bot(Long identity, String action, String closeCase, String comments, String name, String reason) {
this.identity = identity;
this.action = action;
this.closeCase = closeCase;
this.comments = comments;
this.name = name;
this.reason = reason;
}
Obrigado a todos