How can I make a JUnit Test that tests NamedQueries?
I want a fail on syntaxis error like:
@Entity
@NamedQueries({
@NamedQuery(name="Country.findByName",
query="SELECT c FROM Country c WHERE c.wrongname = :name")
})
public class Country {
private String name;
//...
}
The test should be fail because name < > wrongname
I only need syntaxis check, not DB check
StackTrace on runtime:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: unit] Unable to build EntityManagerFactory
...
Caused by: org.hibernate.HibernateException: Errors in named queries: Country.findByName
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:397)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)