Please help as I'm stuck with this, I'm using the Jboss version that comes with JPortal 2.7.1 (just in case that makes any difference) and not using EJB3, just POJOs. It works perfectly with hbm.xml files, but does not work with annotations. Is there anything wrong and/or missing in my code below?
Thanks
Posted: Sat Mar 21, 2009 7:10 am
I deployed a HAR within an EAR with no problems (within an expanded folder) however it works perfectly only with hbm.xml files and I would like to take advantage of annotations and Hibernate doesn't seem to find my class. When Hibernate starts up, the class does not appear in the console log, and when I try to invoke a class, I get "Unknown Entity".
According to what I read so far this should work, what am I missing? my files are below. thanks!!
Version: JBoss AS 4.2.3.GA, Hibernate 3.2.4.sp1, MySql 5.1
xxx.ear/xxx.har/META-INF/jboss-service.xml
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">java:/MySqlDB</attribute>
<attribute name="SessionFactoryName">java:/hibernate/HibernateSessionFactory</attribute>
<attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
<attribute name="ScanForMappingsEnabled">true</attribute>
</mbean>
xxx.ear/xxx.har/hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping class="beans.data.Class1"/>
</session-factory>
</hibernate-configuration>
compiled into xxx.ear/xxx.har/beans/data/Class1.class
package beans.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "table1")
public class Class1 {
@Id
@Column(name = "code")
private Integer code;
@Column(name = "description")
private String description;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
|