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 ManyToOne
relationship in Ability to register a Generation . The generation _id field was created correctly by Hibernate in the Habilidade
table. I'm trying to implement a autoComplete
on my screen and I've read that the completMethod
attribute is responsible for calling the method that will load the objects on the screen. How can I create a method in my Skill controller that searches only for Generation IDs but clicks the Generations names on the screen so I can select one? I want to search for ID's to be a lighter query in the bank.