Hello! I have several *.hbm.xml-Files and want convert them into ejb3-annotated java-files with hibernatetools 3.2.0.beta7. Two Entities (Entity3 and Entity10) are 1:1 connected. I followed the instructions of hibernate-reference implementing the hbm-1:1-relations:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="db.entities.Entity03" table="Entity03">
<id name="idEntity03" type="int">
<column name="idEntity03" />
<generator class="native" />
</id>
<property name="attribute0" type="java.lang.String">
<column name="attribute0" not-null="true" />
</property>
<one-to-one name="entity10_11b" class="db.entities.Entity10" property-ref="entity03_11a"/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="db.entities.Entity10" table="Entity10">
<id name="idEntity10" type="int">
<column name="idEntity10" />
<generator class="native" />
</id>
<many-to-one name="entity03_11a" class="db.entities.Entity03" column="fk_idEntity03_11a" unique="true" />
</class>
</hibernate-mapping>
Here is en excerpt out of my ant-file:
Code:
<hibernatetool destdir="${destdir}">
<configuration configurationfile="${destdir}/hibernate.cfg.xml" />
<hbm2java jdk5="true" ejb3="true" />
</hibernatetool>
This is my hibernate.cfg.xml:
Code:
<!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 resource="db/manager/hibernate/Entity00.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity01.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity02.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity03.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity04.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity05.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity06.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity07.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity08.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity09.hbm.xml"/>
<mapping resource="db/manager/hibernate/Entity10.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Unfortunately I get the following output for my Entity03.java after conversion:
Code:
package db.entities;
// Generated 11.09.2006 13:31:07 by Hibernate Tools 3.2.0.beta7
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Columns;
/**
* Entity03 generated by hbm2java
*/
@Entity
@Table(name="Entity03"
)
public class Entity03 implements java.io.Serializable {
// Fields
private int idEntity03;
private String attribute0;
private Entity10 entity10_11b;
// Constructors
/** default constructor */
public Entity03() {
}
/** minimal constructor */
public Entity03(String attribute0) {
this.attribute0 = attribute0;
}
/** full constructor */
public Entity03(String attribute0, Entity10 entity10_11b) {
this.attribute0 = attribute0;
this.entity10_11b = entity10_11b;
}
// Property accessors
@Id @GeneratedValue
@Column(name="idEntity03", unique=false, nullable=false, insertable=true, updatable=true)
public int getIdEntity03() {
return this.idEntity03;
}
public void setIdEntity03(int idEntity03) {
this.idEntity03 = idEntity03;
}
@Column(name="attribute0", unique=false, nullable=false, insertable=true, updatable=true)
public String getAttribute0() {
return this.attribute0;
}
public void setAttribute0(String attribute0) {
this.attribute0 = attribute0;
}
@Columns( } )
public Entity10 getEntity10_11b() {
return this.entity10_11b;
}
public void setEntity10_11b(Entity10 entity10_11b) {
this.entity10_11b = entity10_11b;
}
}
The error is at "@Columns( } )". Seems, there is a bug in hibernatetools for converting 1:1-relations into ejb3-java-Files out of hbm-files. Can anyone help?