-->
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.  [ 2 posts ] 
Author Message
 Post subject: middlegen/hib plugin primitive types + id gen selection
PostPosted: Thu Jun 03, 2004 9:14 am 
Newbie

Joined: Thu Jun 03, 2004 8:57 am
Posts: 8
I am using hibernate 2.1.3, generating classes from a db with middlegen and hbm2java. I have 2 questions related to its usage.

First, I am wondering how to tell the TypeMapper to use primitive types for my ids (int instead of java.lang.Integer), and second I was wondering if it is possible to set the id generation type somewhere in the middlegen or hbm2java tasks. I would like set the generation type to hilo instead of assigned.

Thanks.

---------------------------------------------------------------------------------

<middlegen
appname="${name}"
prefsdir="${conf.dir}"
gui="${gui}"
databaseurl="${database.url}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
>

<table name="tblAddress" singular="Address" plural="Addresses" />

<!-- skip a few (I have 60+ tables listed here)-->

<table name="tblUserRole" singular="UserRole" plural="UserRoles"/>
<table name="tblWebFile" singular="WebFile" plural="WebFiles"/>

<!-- Plugins -->
<hibernate
destination="${gen-src.dir}"
package="com.${name}.gen"
genXDocletTags="true"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>

</middlegen>

<!-- HBM2JAVA-->
<target name="hbm2java" depends="middlegen"
description="Generate .java from .hbm files.">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="app.class.path"/>

<hbm2java config="${conf.dir}/hibernate.cfg.xml"
output="C:\cvsroot\myproject\src" classpathref="app.class.path">
<fileset dir="${gen-src.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</hbm2java>
</target>

----------------------------------------------------------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 12:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hi,

1) It best not to use primitive type for primary keys hence why the Mapper have been created this way. You can manually change the type using the GUI or you can edit the preferences file. Another option is to write you own java type mapper. This was designed so that you can build you own type associations which is what you have asked.

2) The generator type can be set using the GUI. In the current CVS version (I hope to do a release soon) you can set the generator type but its restricted to only 'assigned' or 'native'. In your case it might best best to edit your preferences file appropriately.

Hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.