Version of Hibernate: 3.2
INFO 02-05 10:06:45,786 (Version.java:<clinit>:15) -Hibernate EntityManager 3.2.0.CR1
INFO 02-05 10:06:45,802 (Version.java:<clinit>:15) -Hibernate Annotations 3.2.0.CR1
INFO 02-05 10:06:45,802 (Environment.java:<clinit>:499) -Hibernate 3.2 cr2
Mapping documents: annotated classes (generated by Hibernate Tools)
domain code located in: <workdir>/src/java/com/abc/greta/test/dataObjects/DemoTable.java
persistence.xml located in: <workdir>/bin/META-INF/persistence.xml
I'm getting the following exception:
Code:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.hql.ast.QuerySyntax
Exception: DemoTable is not mapped [from DemoTable t order by t.name desc]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.
java:567)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:79)
My persistence.xml:
Code:
<persistence-unit name="demotest" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.default_schema" value="GRETA" />
<property name="hibernate.connection.username" value="greta" />
<property name="hibernate.connection.password" value="greta" />
<property name="hibernate.connection.url"
value="jdbc:oracle:thin:@localhost:tactical" />
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.query.factory_class"
value="org.hibernate.hql.ast.ASTQueryTranslatorFactory" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.NoCacheProvider" />
</properties>
</persistence-unit>
</persistence>
Code:
package com.abc.greta.test.dataObjects;
// Generated May 2, 2007 10:05:23 AM by Hibernate Tools 3.2.0.b9
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.SEQUENCE;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
* DemoRadar generated by hbm2java
*/
@Entity
@Table(name = "DEMO_TABLE")
public class DemoTable implements java.io.Serializable {
private Integer Id;
private String name;
private String description;
private Date datetime;
private Boolean simulated;
public DemoRadar() {
}
public DemoRadar(String name) {
this.name = name;
}
public DemoRadar(String name,
String description, Date datetime,
Boolean simulated) {
this.name = name;
this.description = description;
this.datetime = datetime;
this.simulated = simulated;
}
@SequenceGenerator(name = "generator")
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "generator")
@Column(name = "ID", nullable = false, precision = 22, scale = 0)
public Integer getId() {
return this.Id;
}
public void setRadarId(Integer Id) {
this.Id = Id;
}
@Column(name = "NAME", unique = true, nullable = false, length = 10)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "DESCRIPTION", length = 200)
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name = "DATETIME")
public Date getDatetime() {
return this.datetime;
}
public void setDatetime(Date datetime) {
this.datetime = datetime;
}
@Column(name = "SIMULATED", length = 1)
public Boolean isSimulated() {
return this.simulated;
}
public void setSimulated(Boolean simulated) {
this.simulated = simulated;
}
}
Code:
@SuppressWarnings("unchecked")
public Vector<DemoTable> getDemoTables() {
Vector<DemoTable> demoTables = null;
demoTables = (Vector<DemoRadar>) em.createQuery("from DemoTable t " +
"order by t.name desc")
.getResultList();
return demoTables;
}
I can not figure this out!! Driving me nuts!! Why isn't Ejb3Configuration finding my annotated classes?????
Possible useful debug information (from before the exception):
Code:
INFO 02-05 10:06:45,833 (Environment.java:<clinit>:532) -hibernate.properties not found
INFO 02-05 10:06:45,833 (Environment.java:buildBytecodeProvider:666) -Bytecode provider name : cgl
ib
INFO 02-05 10:06:45,833 (Environment.java:<clinit>:583) -using JDK 1.4 java.sql.Timestamp handling
DEBUG 02-05 10:06:45,928 (Ejb3Configuration.java:createEntityManagerFactory:165) -Trying to find pe
rsistence unit: demotest
DEBUG 02-05 10:06:45,928 (Ejb3Configuration.java:createEntityManagerFactory:174) -Analyse of persis
tence.xml: file:/D:/workspace/bin/META-INF/persistence.xml
DEBUG 02-05 10:06:46,226 (PersistenceXmlLoader.java:parsePersistenceUnit:115) -Persistent Unit name
from persistence.xml: demotest
DEBUG 02-05 10:06:46,226 (Ejb3Configuration.java:getDetectedArtifacts:476) -Detect class: true; det
ect hbm: false
DEBUG 02-05 10:06:46,226 (Ejb3Configuration.java:createEntityManagerFactory:186) -Archive to be pro
cessed by hibernate Entity Manager implementation found
DEBUG 02-05 10:06:46,226 (JarVisitor.java:unqualify:185) -Searching mapped entities in jar/par: fil
e:/D:/workspace/bin
DEBUG 02-05 10:06:46,226 (Ejb3Configuration.java:createEntityManagerFactory:193) -Persistence unit
name: demotest
DEBUG 02-05 10:06:46,226 (Ejb3Configuration.java:createEntityManagerFactory:195) -emname:demotest metadata: demotest
FATAL 02-05 10:06:46,258 (Ejb3Configuration.java:accept:514) -META-INF/persistence.xmlO:Ofalse
DEBUG 02-05 10:06:46,258 (Ejb3Configuration.java:createFactory:124) -Creating Factory: demotest
WARN 02-05 10:06:46,258 (Ejb3Configuration.java:prepareProperties:875) -Defining hibernate.transac
tion.flush_before_completion=true ignored in HEM
DEBUG 02-05 10:06:46,258 (AnnotationConfiguration.java:secondPassCompile:232) -Execute first pass m
apping processing
DEBUG 02-05 10:06:46,305 (AnnotationConfiguration.java:processArtifactsOfType:336) -Process hbm fil
es
DEBUG 02-05 10:06:46,305 (AnnotationConfiguration.java:processArtifactsOfType:344) -Process annotat
ed classes
DEBUG 02-05 10:06:46,305 (AnnotationConfiguration.java:secondPassCompile:282) -processing manytoone
fk mappings
DEBUG 02-05 10:06:46,305 (Configuration.java:secondPassCompile:1039) -processing extends queue
DEBUG 02-05 10:06:46,305 (Configuration.java:secondPassCompile:1043) -processing collection mapping
s
DEBUG 02-05 10:06:46,305 (Configuration.java:secondPassCompile:1054) -processing native query and R
esultSetMapping mappings
DEBUG 02-05 10:06:46,305 (Configuration.java:secondPassCompile:1062) -processing association proper
ty references
DEBUG 02-05 10:06:46,305 (Configuration.java:secondPassCompile:1084) -processing foreign key constr
aints
WARN 02-05 10:06:46,321 (Ejb3Configuration.java:createEntityManagerFactory:756) -hibernate.connect
ion.autocommit = false break the EJB3 specification
DEBUG 02-05 10:06:46,321 (Configuration.java:buildSessionFactory:1204) -Preparing to build session
factory with filters : {}
DEBUG 02-05 10:06:46,321 (AnnotationConfiguration.java:secondPassCompile:232) -Execute first pass m
apping processing
DEBUG 02-05 10:06:46,321 (AnnotationConfiguration.java:processArtifactsOfType:336) -Process hbm fil
es
DEBUG 02-05 10:06:46,321 (AnnotationConfiguration.java:processArtifactsOfType:344) -Process annotat
ed classes
DEBUG 02-05 10:06:46,321 (AnnotationConfiguration.java:secondPassCompile:282) -processing manytoone
fk mappings
DEBUG 02-05 10:06:46,321 (Configuration.java:secondPassCompile:1039) -processing extends queue
DEBUG 02-05 10:06:46,321 (Configuration.java:secondPassCompile:1043) -processing collection mapping
s
DEBUG 02-05 10:06:46,321 (Configuration.java:secondPassCompile:1054) -processing native query and R
esultSetMapping mappings
DEBUG 02-05 10:06:46,321 (Configuration.java:secondPassCompile:1062) -processing association proper
ty references
DEBUG 02-05 10:06:46,321 (Configuration.java:secondPassCompile:1084) -processing foreign key constr
aints