-->
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.  [ 1 post ] 
Author Message
 Post subject: Using xdoclet and schemaexport with enums
PostPosted: Mon Dec 13, 2004 8:29 pm 
Newbie

Joined: Thu Apr 22, 2004 7:45 pm
Posts: 2
Location: Des Moines, Iowa, US
Hibernate version: 2.1.4
Xdoclet version: 1.2
Name and version of the database: MS SQL Server 2000

Build process:

We are using Ant to run an Xdoclet task to generate *.hbm.xml files from javadoc metadata in our Java source files, then using the schemaexport task to generate a schema.ddl document from the *.hbm.xml files.

Description of issue:

As with many applications, we have enums in our domain model. We have created UserType classes for them, and we're currently mapping them as properties (@hibernate.property) when referenced by other classes.

Unfortunately, when mapping enums as properties, the schemaexport task does not generate a separate "domain data" table (as we call them) and foreign key references from the original tables that contain enum codes.

However, if I map the enum as a @hibernate.many-to-one relationship in the containing class and map the enum Java source using @hibernate.class and the requisite property tags, then the table and the foreign keys are generated for me by the schemaexport task. But then I can't model the enums properly through Hibernate since it wants to construct the enum by calling a default constructor and setting the properties on the enum individually.

The question:

I want to map the enums as both a property (for use in production) and as a many-to-one relationship (only for generating the database schema).

Has anyone found (or created) a good solution for this dichotomy of enum mappings? I'm afraid I'm going to have to use some kind of two-pass mechanism in our build.xml script to generate one set of *.hbm.xml files for schemaexport and another set of *.hbm.xml files for the application.

I could also see creating a special @hibernate.enum tag that would behave as a @hibernate.property tag or a @hibernate.many-to-one tag, depending on a setting passed into the Xdoclet task.

Or am I going about this problem all wrong? I have read through these documents, but they don't seem to solve the problem I'm having:

UserType for persisting Typesafe Enumerations with a single class
UserType for persisting a Typesafe Enumeration with a VARCHAR column

Thanks for any help you may provide!

Dave


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

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.