hi guys,
First of all, thanks Max for pointing me to the right topic, kudos to him!
I run into an odd problem.
We are using hbm2java target to autogenerate Hibernate mappings and beans from the database. And it's failing because the xdoclet annotations generated in the PoJos are incorrect
I expect the annotation for a getter method to look like below:
/**
* @hibernate.id
* generator-class="assigned"
* type="java.lang.String"
* column="ORG_UNIT_SYS_ID"
*
*/
public String getOrgUnitSysId() {
return this.orgUnitSysId;
}
However, I am getting this instead:
/**
* @hibernate.property
* column="ORG_UNIT_SYS_ID"
* length="80"
*
*/
public String getOrgUnitSysId() {
return this.orgUnitSysId;
}
The database script used to create the table:
CREATE TABLE ORG_UNIT
(
ORG_UNIT_SYS_ID VARCHAR2(80 BYTE) NOT NULL,
ORG_UNIT_CODE VARCHAR2(8 BYTE),
REF_ORG_UNIT_CODE VARCHAR2(8 BYTE),
ORG_UNIT_DESC VARCHAR2(200 BYTE),
LEAVE_TYPE_CODES VARCHAR2(4000 BYTE)
)
I am using the vanilla code generation configuration in hbm2java.config
<codegen>
<meta attribute="scope-field">protected</meta>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
</codegen>
In addition, the middlegen is called to before hand to generate a flat mapping. And for the table, I got the following entry:
hibernate.tables.ORG_UNIT.base-class-name=OrgUnit
hibernate.tables.ORG_UNIT.columns.LEAVE_TYPE_CODES.java-name=leaveTypeCodes
hibernate.tables.ORG_UNIT.columns.LEAVE_TYPE_CODES.java-type=java.lang.String
hibernate.tables.ORG_UNIT.columns.ORG_UNIT_CODE.java-name=orgUnitCode
hibernate.tables.ORG_UNIT.columns.ORG_UNIT_CODE.java-type=java.lang.String
hibernate.tables.ORG_UNIT.columns.ORG_UNIT_DESC.java-name=orgUnitDesc
hibernate.tables.ORG_UNIT.columns.ORG_UNIT_DESC.java-type=java.lang.String
hibernate.tables.ORG_UNIT.columns.ORG_UNIT_SYS_ID.java-name=orgUnitSysId
hibernate.tables.ORG_UNIT.columns.ORG_UNIT_SYS_ID.java-type=java.lang.String
hibernate.tables.ORG_UNIT.columns.REF_ORG_UNIT_CODE.java-name=refOrgUnitCode
hibernate.tables.ORG_UNIT.columns.REF_ORG_UNIT_CODE.java-type=java.lang.String
The middlegen target itself is pretty straight forward, the prefsdir is where the properties file for middlegen.
<middlegen
appname="ProjectA"
gui="false"
prefsdir="${target.core.middlegenprefs}"
databaseurl="${environment.database.url}"
driver="${environment.database.driver}"
username="${environment.database.user}"
password="${environment.database.password}"
schema="${environment.database.schema}"
catalog="${environment.database.catalog}">
<!-- Plugins -->
<hibernate
destination="${target.core.hibernatemappings}"
package="${target.middlegen.package}"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
genXDocletTags="true"/>
**** list of tables ******
</middlegen>
Is there something wrong here that could cause middlegen to throw a fit?
apologies for the length of this post.
thanks,
pali
|