I noticed that named queries modeled with UML are generated as annotations in entity classes. For example :
- Code: Select all
@javax.persistence.Entity
@javax.persistence.Table(name = "EMPLOYE")
// Uncomment to enable entity listener for Employe
// @javax.persistence.EntityListeners({fr.horoquartz.t4.core.employe.EmployeListener.class})
// Uncomment to enable caching for Employe
// @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.TRANSACTIONAL)
@javax.persistence.NamedQueries
({
@javax.persistence.NamedQuery(name = "Employe.findAll", query = "select employe from Employe AS employe"),
@javax.persistence.NamedQuery(name = "Employe.findByMatricule", query = "from Employe as employe where employe.matricule = :matricule"),
@javax.persistence.NamedQuery(name = "Employe.findByPrenom", query = "from Employe as employe where employe.prenom = :prenom"),
@javax.persistence.NamedQuery(name = "Employe.findByPays", query = "from Employe as employe where employe.pays = :pays")
})
public class Employe
extends fr.horoquartz.t4.core.employe.EmployeEmbeddable
implements java.io.Serializable, Comparable<Employe>
{
...
But since these classes are generated in the core/src/main/java directory, which is written once, does it mean you have to change the query in both UML model and Java sources if you change a query ?
I am a newbie with EJB3, so maybe this is not a serious issue, but please tell me
