Hibernate version: 2.1.4
Mapping documents: included
Code between sessionFactory.openSession() and session.close(): n/a
Full stack trace of any exception that occurs:
Name and version of the database you are using: n/a
Debug level Hibernate log excerpt: n/a
My mapping file specifies to generate an inner class by using the Foo$Bar notation as stated in the Hibernate manual, however, when I run hbm2java, it is generating the class as a separate file, with the name given and the desied outer class is not referring to it as Id.
My RecordingBean$Id class is not being generated inside my RecordingBean class... What am I doing wrong? Here are excerpts from the files:
Mapping file:
<hibernate-mapping schema="weblogic" package="relationships">
<class name="RecordingBean" table="RECORDING" lazy="true">
<meta attribute="class-description">
This JavaBean class is for interacting with the RECORDING
table.
@author Me
</meta>
<composite-id name="id" class="RecordingBean$Id" unsaved-value="any">
<key-property name="bandname" type="string" column="BANDNAME">
<meta attribute="field-description">Returns band's name.</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
<key-property name="title" type="string" column="TITLE">
<meta attribute="field-description">Returns recording name.</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
</composite-id>
Ant task to generate the file:
<java classname="net.sf.hibernate.tool.hbm2java.CodeGenerator">
<arg value="${src.dir}/relationships/RecordingBean.hbm.xml"/>
<classpath refid="compile.classpath"/>
</java>
Output files generated:
package relationships;
import RecordingBean$Id;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* This JavaBean class is for interacting with the RECORDING
* table.
* @author Me
*
*/
public class RecordingBean implements Serializable {
/** identifier field */
private RecordingBean$Id id;
...
}
package relationships;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* This JavaBean class is for interacting with the RECORDING
* table.
* @author Me
*
*/
public class RecordingBean$Id implements Serializable {
/** identifier field */
private String bandname;
/** identifier field */
private String title;
/** full constructor */
public RecordingBean$Id(String bandname, String title) {
this.bandname = bandname;
this.title = title;
}
/** default constructor */
public RecordingBean$Id() {
}
...
}
|