0
Guys, please, could someone show me how to call in the main @Namedquery class of another class. Follow the example:
@Entity
@Table(name="edificio")
@NamedQuery(name="consultaEdificioPorChavePrimaria",query="select e from Edificio e where e.id = :id")
public class Edificio implements Serializable {
//codigo
}
I truly thank you. I embrace you all!
Try to provide more details of your problem and if possible an example Minimum, Complete and Verifiable of what you’re trying to accomplish.
– Marlon Bahniuk
Hey, buddy, what’s up? I’m learning JPA in a book, and I did a personal example of building registration and he comments on various ways to pull a list from the database and one is the example. Place Annotation in the class you want to list, print database data. The Annotation is @Namedquery. I wonder how I do that in the main,view class, I call that Edificio class the Annotation that indicates to print the information to be compiled.
– Gabriel Araújo
Gabriel to use @Namedquery you need to be with all JPA already configured. If this is the case you can make the call as follows:
em.createNamedQuery("Edificio.consultaEdificioPorChavePrimaria").setParameter("id", "foo").getResultList();
– Marlon Bahniuk
@Marlonbahniuk, post your comment as reply :)
– Dherik