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.  [ 5 posts ] 
Author Message
 Post subject: Composite key code generation failure
PostPosted: Wed Aug 16, 2006 5:17 pm 
Newbie

Joined: Wed Aug 16, 2006 4:25 pm
Posts: 3
Location: Denver
Hi I am using Hibernate Tools 3.2.0 Beta 6a and Hibernate 3.1.3 to try and generate the DAO's and POJO's for my project. I am running this from an ant task using java 1.4.2.12 and the database is Oracle 9i. I am able to generate these fine for any table that does not have a composite key. Any table that has a composite key generates the hbm but gives a stacktrace.

The stacktrace is:
An exception occurred while running exporter #2:generic exporter
To get the full stack trace run ant with -verbose
org.hibernate.tool.hbm2x.ExporterException: Error while processing template hibernate-mapping.hbm.ftl
freemarker.template.TemplateModelException: No signature of method getTag matches (org.hibernate.mapping.Component)
C:\projects\hibernate\hib3\build.xml:117: org.hibernate.tool.hbm2x.ExporterException: Error while processing template hibernate-mapping.hbm.ftl

I have seen from several post ideas to add entries to the DAO.ftl with no success. Does anyone have a solution to generating against a table with composite keys?

Any help would be greatly appreaciated.

John

Here is the ant task that I am running:
[code]<target name="hibtools" depends="init">
<echo message="generating the hbms"/>
<hibernatetool destdir="${build.gensrc.dir}">
<jdbcconfiguration configurationfile="${resources.dir}\Hibernate.Config.hbm.xml"
packagename="persistence"
revengfile="${resources.dir}\Hibernate-RevEng.xml">
</jdbcconfiguration>

<hbmtemplate
templatepath="${resources.dir}\ftl"
template="hibernate-mapping.hbm.ftl"
filepattern="{package-name}/{class-name}.hbm.xml">
<property key="jdk5" value="false"/>
<property key="ejb3" value="false"/>
<property key="default-cascade" value="all"/>
<property key="verbose" value="true"/>
</hbmtemplate>
</hibernatetool>

<echo message="hbms generated"/>
<hibernatetool destdir="${build.gensrc.dir}">
<configuration>
<fileset dir="${build.gensrc.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbmtemplate
templatepath="${resources.dir}\ftl"
template="Pojo.ftl"
filepattern="{package-name}/{class-name}.java">
<property key="jdk5" value="false"/>
<property key="ejb3" value="false"/>
</hbmtemplate>


<hbmtemplate
templatepath="${resources.dir}\ftl"
template="DAO.ftl"
filepattern="{package-name}/{class-name}DAO.java">
<property key="jdk5" value="false"/>
<property key="ejb3" value="false"/>
<property key="sessionFactoryName" value="java:/hibernate/SessionFactory"/>
</hbmtemplate>
</hibernatetool>[/code]

Here is a script to create the table in question:
[code]CREATE TABLE INVENTORY_FULFILLMENT_METHOD
(
ITEM_ID CHAR(20) NOT NULL,
FULFILLMENT_METHOD_CODE VARCHAR2(2) NOT NULL,
IS_DEFAULT VARCHAR2(1) DEFAULT 'N',
CREATED_BY VARCHAR2(80),
CREATED_ON DATE,
UPDATED_BY VARCHAR2(80),
UPDATED_ON DATE
)
TABLESPACE WIMS_DATA
PCTUSED 40
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 10M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
)
LOGGING
NOCACHE
NOPARALLEL;


CREATE UNIQUE INDEX INV_FULF_METHOD_PK ON INVENTORY_FULFILLMENT_METHOD
(ITEM_ID, FULFILLMENT_METHOD_CODE)
LOGGING
TABLESPACE WIMS_INDEX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 10M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
)
NOPARALLEL;


CREATE PUBLIC SYNONYM INVENTORY_FULFILLMENT_METHOD FOR INVENTORY_FULFILLMENT_METHOD;


ALTER TABLE INVENTORY_FULFILLMENT_METHOD ADD (
CONSTRAINT INV_FULF_METHOD_PK PRIMARY KEY (ITEM_ID, FULFILLMENT_METHOD_CODE)
USING INDEX
TABLESPACE WIMS_INDEX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 10M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
));


ALTER TABLE INVENTORY_FULFILLMENT_METHOD ADD (
CONSTRAINT INV_FULF_FULFILLMENT_FK FOREIGN KEY (FULFILLMENT_METHOD_CODE)
REFERENCES FULFILLMENT_METHOD (CODE));

ALTER TABLE INVENTORY_FULFILLMENT_METHOD ADD (
CONSTRAINT INV_FULF_INV_FK FOREIGN KEY (ITEM_ID)
REFERENCES INVENTORY (OBJECT_ID));
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 12:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
why are you using hbmtemplate for all those that has shorthand names ?

It should work, but just curious ? :)


And compositekey should definitly also work for compositeid's otherwise alot of our junit tests would fail.

Could you try and isolate the error and put a failing example into our jira ?
thanks

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 12:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
do note dao and seamgen has compositekey issues.

hbm2java and hbm2hbmxml should definitly not have those issues.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: More information
PostPosted: Thu Aug 17, 2006 3:57 pm 
Newbie

Joined: Wed Aug 16, 2006 4:25 pm
Posts: 3
Location: Denver
I have been playing with this more and have noticed some changes in the hbm file that is generated when a composite primary key is present.

I have created a simple table that has 2 columns and created a primary key on them. I have also tried it without the primary key knowing that hibernate will treat all the columns as the key. What I have found is that if the primary key is a composite it fails, yet if I create a simple primary key off 1 column it autogenerates fine.

I will create an item in Jira as well as continue to look into this to get more information. Has anyone else run into this problem and have a work around beside removing the composite key?

Here is a the simple scripts I used to create the tests and run through:
CREATE TABLE JGG_TEST2
(
ITEM_ID CHAR(20) NOT NULL,
FULFILLMENT_METHOD_CODE VARCHAR2(2) NOT NULL
)
TABLESPACE WIMS_DATA
PCTUSED 40
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 10M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
)
LOGGING
NOCACHE
NOPARALLEL;

ALTER TABLE JGG_TEST2 ADD (
CONSTRAINT JGG_TEST2_PK PRIMARY KEY (ITEM_ID,FULFILLMENT_METHOD_CODE)
USING INDEX
TABLESPACE WIMS_INDEX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 10M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
));


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 1:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
we have explicit tests for compoisite keys for pojo and hbm.xml generation.

IF that is what is failing (and not dao or seam generation) then please do add a jira with enough information to reproduce it + what is the stacktrace exactly.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.