-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: middlegen xdoclet annotations
PostPosted: Mon Jan 22, 2007 6:38 am 
Newbie

Joined: Sun Jan 21, 2007 10:56 pm
Posts: 14
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 6:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
btw. a good guess is that your table does not have a primary key thus its id column is just generated as a normal property.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 9:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Max is correct - Middlegen looks for the primary key. Once you set it it will be happy to apply the generator attributes.


Top
 Profile  
 
 Post subject: db script
PostPosted: Mon Jan 22, 2007 10:31 pm 
Newbie

Joined: Sun Jan 21, 2007 10:56 pm
Posts: 14
thanks max,

it's the missing primary key. the db is new, must have missed this information somehow.

cheers,

pali


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.