-->
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.  [ 10 posts ] 
Author Message
 Post subject: Which revision of HibernateExt to checkout to work with v313
PostPosted: Thu Jul 27, 2006 3:52 am 
Newbie

Joined: Thu Jul 27, 2006 3:46 am
Posts: 5
Hi All,

I need to make a small modification to some hibernate code, but I am struggling with finding the right svn revision of HibernateExt (especially tools and common) that compiles against the v313 tagged version of Hibernate3. Yesterda\y I spent quite some time on checking out several revisions that I thought should be compliant, but no luck and At this moment I more or less do not know how to proceed. Can anyone help?

Regards, Martin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 4:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate tools generates code that works with 3.x.

just use the hibernate jar that comes with the tools.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 5:04 am 
Newbie

Joined: Thu Jul 27, 2006 3:46 am
Posts: 5
max wrote:
hibernate tools generates code that works with 3.x.

just use the hibernate jar that comes with the tools.


Would have been an option, but I think I need to make a small modification to both the tool as well as to hibernate and thus I need to be able to compile them both and they need to work with each other. For some projects I would like to use some self-defined types (in fact, a kind of EnumUserType, which is a wrapper around some enum class (got some code from somewhere on the hibernate site), but I do not have the actual enum classes available when creating java classes with the hibernate tools. But currentlz it seems to be required to have these types available at the time the code is generated.
I looked at some code and basically the code uses a construct that a CustomType is asked for a Class, and the Cfg2JavaTool get"s the name of that class, but this fails if the CustomType fails to call the getReturnedClass of my usertype (as I only know the classname at that time, but cannot instantiate that class). For this I would like to make a local modification to CustomerType as well as the Cfg2JavaTool, as this should circumvent mzyproblem at this moment.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 5:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well you will have to go waaaay back to get something compliant with 3.1 afaik.

I would still suggest you give me a testcase that fails in this regard

...because from your description you are not providing enough info in the hbm.xml files for codegeneration to work at all or you did discover a genuine bug.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 5:34 am 
Newbie

Joined: Thu Jul 27, 2006 3:46 am
Posts: 5
max wrote:
well you will have to go waaaay back to get something compliant with 3.1 afaik.
max wrote:

So you"re suggesting to do some trial and error as it is unknown which (tagged) revision of hibernate3 is included in tools? I could not find any (late) tags for tools in the svn repo either

max wrote:
I would still suggest you give me a testcase that fails in this regard

...because from your description you are not providing enough info in the hbm.xml files for codegeneration to work at all or you did discover a genuine bug.


As far as I could determine, for the code generation step I only needed two things:
1) the classname of my enum type (the tool now falls back to the EnumUserType class name, as the returnedClass() method obvisouly generates an exception when I try to return the class that is not yet available (ClassNotFound)
2) the sql type of the column that stores the enum id. I can provide this as a property to my UserType

Basically it all works, but the resulting code now has methods that take or return the EnumUserType (because the code falls back to this when the returnedClass() method fails), instead of my ActualEnumType...

I do not see this as a bug (and I do not think it is), it is just that I would like to have the code prevent to do a Class.forName("someClassName").getName() in this case, what is happening in fact indirectly at this moment.

I could live with a different version of hibernate/tools, but it woul be nice to know which tagged versions I could use for this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 5:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
No, I know very clearly what version of hibernate that works with the tools. It is Hibernate 3.2 SVN HEAD (should also work fine with latest release, but that is not the one i'm developing against at the moment.)

It is normal to use hibernate.jar from tools with tools and some production specfici hibernate 3.1.x release for your "normal" hibernate usage.

When 3.2 gets released in final it will be the one of the releases that gets included.

Why is the class not found ?
It should be in the classpath, right ? That is what you do with all custom types.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 5:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sorry, did not see you already answering that question ;)

Ok, 2 things:

1) Why are they not available ? (just curious since i don't know of such usecase ;)

2) you can use <meta attribute="property-type">blah</meta> to force it per property. No need for hacks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 5:55 am 
Newbie

Joined: Thu Jul 27, 2006 3:46 am
Posts: 5
max wrote:
Why is the class not found ?
It should be in the classpath, right ? That is what you do with all custom types.


May be a sample explains more clearly what I try to do. See some hbn.xml fragment below:

<typedef name="EmployeeActivityType" class="com.sample.hbn.EnumUserType">
<param
name="enumClassName">com.sample.model.MyLittleEnum</param>
<param
name="enumSqlType">INTEGER</param>
</typedef>
...

<class>
...
<property name="activityType" column="activity_type" type="EmployeeActivityType"/>
...
</class>

The EnumUserType I am using is more or less based on the GenericEnumUserType in http://www.hibernate.org/272.html,
with the addition that the Sql type is taken from the hbn.xml file.

The point is that the class com.sample.model.MyLittleEnum is NOT available when the classes are generated. This class is in the destination project, where it can be compiled together with the by the tool generated java classes. In some of the projects I am in, this would be a big win.

When the EnumUserType would not be asked for the actual class (though the returnedClass method in EnumUserType, but just for the name, the problem would be solved.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 6:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - code is (almost) always better for explaining technical details ;)

So you want to generate code for a class you cannot load nor compile against...then the only supported way is to put <meta attribute="property-type"> in there.

btw. any reason why you are not using the enum usertype from the annotations project?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 6:40 am 
Newbie

Joined: Thu Jul 27, 2006 3:46 am
Posts: 5
max wrote:
So you want to generate code for a class you cannot load nor compile against...then the only supported way is to put <meta attribute="property-type"> in there.

btw. any reason why you are not using the enum usertype from the annotations project?


I tried <meta attribute="property-type">, this indeed seems to solve the issue (did not try to persist it yet). I now only have to supply the sql type, which is successfull, through my enum usertype. I"ll pursue this further

Why I"m not using the enum usertype from the annotations project? "Ignorance" I must say :-(

You're help has been great so far, I'll try to implement the solution you suggested.


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