Discussion:
[Middlegen-user] Middlegen 2.0 maps nullable fields to primitives?
Matthew Schleindl
2004-10-21 11:26:44 UTC
Permalink
Hi -

I'm using 2.0 against Oracle 9.1, and Middlegen
appears to be mapping nullable number fields to
primitive java types like 'short', instead of nullable
wrapper types like 'Short'.

The generated hbm.xml's seem to correctly identify
which fields are nullable and which are not: the
non-nullable fields all are marked not-null="true",
the nullable fields omit the non-null attribute, so it
appears to determine field nullability correctly.

I must be doing something really idiotic.

Thanks in advance,
Matt

PS: I get the same result using 2.1
bruce sherrod
2004-10-21 17:42:44 UTC
Permalink
Is it possible to set the <cache usage="..."> tags in the hibernate
mapping files, when using middlegen to generate the mappings?

My build.xml reads as follows:

<target name="middlegen" description="Run Middlegen to generate .hbm from live running database" >
<echo message="Class path = ${basedir}"/>
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask" />
<property name="name" value="foo"/>
<middlegen
appname="${name}"
prefsdir="${src}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}" >
<hibernate
destination="${src}"
package="com.foo.db"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
standardGeneratorScheme="vm"
/>
</middlegen>
</target>

Mapping files that created look, for example, like this:

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="Account"
table="account"
<id
name="id"
type="java.lang.Integer"
column="id"
<generator class="vm" />
</id>
...

I'd really like the mapping files to have, say, this:

<class
name="Account"
table="account"
<cache usage="read-write"/> <----- this is what I want to have added!
<id
name="id"
type="java.lang.Integer"
column="id"
<generator class="vm" />
</id>
...

How do I do this?

Thanks,
-- Bruce
Eivind Waaler
2004-10-22 06:44:39 UTC
Permalink
I don't think the <cache> element is supported by Middlegen yet. To add
support yourself, check out the source from cvs and add it to the
hibernate.vm file in the hibernate plugin directory.

.eivind
Post by bruce sherrod
Is it possible to set the <cache usage="..."> tags in the hibernate
mapping files, when using middlegen to generate the mappings?
<target name="middlegen" description="Run Middlegen to generate .hbm from live running database" >
<echo message="Class path = ${basedir}"/>
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask" />
<property name="name" value="foo"/>
<middlegen
appname="${name}"
prefsdir="${src}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}" >
<hibernate
destination="${src}"
package="com.foo.db"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
standardGeneratorScheme="vm"
/>
</middlegen>
</target>
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="Account"
table="account"
<id
name="id"
type="java.lang.Integer"
column="id"
<generator class="vm" />
</id>
...
<class
name="Account"
table="account"
<cache usage="read-write"/> <----- this is what I want to have added!
<id
name="id"
type="java.lang.Integer"
column="id"
<generator class="vm" />
</id>
...
How do I do this?
Thanks,
-- Bruce
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...