2
In my JSF + Primefaces project, I have the following entities:
@Entity
@Table(name = "geracao")
public class Geracao {
@Getter
@Setter
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Getter
@Setter
@NotBlank(message = "Nome não pode estar em branco.")
@Pattern(regexp = "[A-z]*", message = "Atenção, digite somente letras")
@Size(max = 20, message = "Máximo de 20 caracteres permitidos.")
@Column(length = 20, nullable = false)
private String nome;
@Getter
@Setter
@Min(1)
@Max(7)
private Integer numero;
@Getter
@Setter
@Column(name = "total_pokemons", nullable = false)
private Integer totalPokemons;
public Geracao() {
}
}
@Entity
@Table(name = "habilidade", uniqueConstraints = @UniqueConstraint(columnNames = { "nome" }))
public class Habilidade {
@Getter
@Setter
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Getter
@Setter
@NotBlank(message = "Nome não pode estar em branco.")
@Pattern(regexp = "[A-z]*", message = "Atenção, digite somente letras")
@Size(max = 20, message = "Máximo de 20 caracteres permitidos.")
@Column(length = 20, nullable = false)
private String nome;
@Getter
@Setter
@NotBlank
@Size(max = 150, message = "Máximo de 150 caracteres permitidos.")
@Column(length = 150, nullable = false)
private String descricao;
@Getter
@Setter
@NotBlank
@Size(max = 150, message = "Máximo de 150 caracteres permitidos.")
@Column(name = "texto_in_game", length = 150, nullable = false)
private String textoInGame;
@Getter
@Setter
@Column(length = 150, name = "efeito_secundario", nullable = true)
private String efeitoSecundario;
@Getter
@Setter
@ManyToOne
private Geracao geracao;
public Habilidade() {
}
}
I have a relationship ManyToOne
in Skill to register a Generation. The field generation_id was created correctly by Hibernate in the table Habilidade
. I’m trying to implement on my screen a autoComplete
and I read that the attribute completMethod
is responsible for calling the method that will load the objects on the screen. How can I create a method in my Ability controller that looks only for Generation ID’s but click on the screen the Generations names so I can select one ? I want to search for ID’s to be a lighter consultation at the bank.
Thank you, what’s the point ?
– Roknauta
The session, serves to open a session of Hibernate to access the data of the database and through the Criteria tbm of Hibernate, makes the search in the database and stores in the variable result.
– Valdoms
As I use the dependency injection, I’ll need it anyway ?
– Roknauta
In your case also he looks for a specific id right? I want him to search all.
– Roknauta
About the addiction injection I can’t tell you.
– Valdoms
Really, the method is looking for a specific id. I’m sorry I made the wrong method. I’ll edit and put the correct method. "list".
– Valdoms
You can post your getFabricaDessodes method() ?
– Roknauta