-->
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.  [ 9 posts ] 
Author Message
 Post subject: Artifact generation not generating toString(), hashCode(), e
PostPosted: Tue Nov 08, 2005 10:28 pm 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
HibernatTools 3.1.0 beta1
Eclipse 3.1
JDK 1.4

The artifact generation from the Eclipse plugin is not generating the toString(), hashCode(), and equals() method.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 1:29 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
Not sure if this is related, but it looks like it is. Hibernet-tools (3.1-beta1 ) seems to be calling Property.isNaturalIdentifier(), which does not exist anymore in hibernate3.jar

I get the following if I try to run hbm2java from the hibernate-tools in eclipse myself:

BUILD FAILED
/home/jsalvo/workspace/softgame-latest/build-hibernate.xml:23: org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while processing template Pojo. Invocation of method 'get' in class org.hibernate.tool.hbm2x.TemplateHelper$Templates threw exception class org.hibernate.tool.hbm2x.ExporterException : MethodInvocationException while processing template pojo/PojoEqualsHashcode.vm. Invocation of method 'needsEqualsHashCode' in class org.hibernate.tool.hbm2x.pojo.EntityPOJOClass threw exception class java.lang.NoSuchMethodError : org.hibernate.mapping.Property.isNaturalIdentifier()Z


Buildfile: /home/jsalvo/workspace/softgame-latest/build-hibernate.xml
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] 9/11/2005 16:24:34 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.0.5
[hibernatetool] 9/11/2005 16:24:34 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 9/11/2005 16:24:34 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using CGLIB reflection optimizer
[hibernatetool] 9/11/2005 16:24:34 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 9/11/2005 16:24:35 org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate-test.cfg.xml
[hibernatetool] 9/11/2005 16:24:35 org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: Hibernate-SybaseTest
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/Campaign.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.Campaign -> campaign
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/CampaignTemplate.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.CampaignTemplate -> campaign_template
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/Carrier.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.Carrier -> carrier
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/CarrierNumber.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.CarrierNumber -> carrier_number
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/Client.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.Client -> client
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/NumberRegister.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.NumberRegister -> number_register
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/ProvisioningRequest.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.ProvisioningRequest -> provisioning_request
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/ProvisioningRequestHistory.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.ProvisioningRequestHistory -> provisioning_request_history
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/ProvisioningRequestTemplate.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.ProvisioningRequestTemplate -> provisioning_request_template
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/ProvisioningUser.hbm.xml
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: com.mig.provisioning.db.hibernate.ProvisioningUser -> provisioning_user
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing extends queue
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing collection mappings
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.Campaign.campaignTemplates -> campaign_template
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.Campaign.provisioningRequests -> provisioning_request
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.Carrier.carrierNumbers -> carrier_number
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.CarrierNumber.provisioningRequests -> provisioning_request
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.Client.campaigns -> campaign
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.NumberRegister.carrierNumbers -> carrier_number
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.NumberRegister.campaigns -> campaign
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.ProvisioningRequest.provisioningRequestTemplates -> provisioning_request_template
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.ProvisioningRequest.provisioningRequestHistories -> provisioning_request_history
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
[hibernatetool] INFO: Mapping collection: com.mig.provisioning.db.hibernate.ProvisioningUser.provisioningRequestHistories -> provisioning_request_history
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing association property references
[hibernatetool] 9/11/2005 16:24:36 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing foreign key constraints
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: **************************************************************
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Starting Jakarta Velocity v1.4
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: RuntimeInstance initializing.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Trying to use logger class org.apache.velocity.tools.generic.log.CommonsLogLogSystem
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Using logger class org.apache.velocity.tools.generic.log.CommonsLogLogSystem
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Resource Loader Instantiated: org.apache.velocity.runtime.resource.loader.FileResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: FileResourceLoader : initialization starting.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: FileResourceLoader : adding path '.'
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: FileResourceLoader : initialization complete.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Resource Loader Instantiated: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ClasspathResourceLoader : initialization starting.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ClasspathResourceLoader : initialization complete.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceCache : initialized. (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Default ResourceManager initialization complete.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Literal
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Macro
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Parse
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Include
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Created: 20 parsers.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : initialization starting.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : allowInline = true : VMs can be defined inline in templates
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : messages on : VM system will output logging messages
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : autoload off : VM system will not automatically reload global library macros
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : initialization complete.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocity successfully started.
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/Pojo.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoTypeDeclaration.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/Ejb3TypeDeclaration.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoFields.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoConstructors.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoPropertyAccessors.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/Ejb3PropertyGetAnnotation.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/Ejb3PropertyGetAnnotation.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/Ejb3PropertyGetAnnotation.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/Ejb3PropertyGetAnnotation.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoToString.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/PojoEqualsHashcode.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] SEVERE: Method needsEqualsHashCode threw exception for reference $pojo in template pojo/PojoEqualsHashcode.vm at [1,5]
[hibernatetool] 9/11/2005 16:24:37 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] SEVERE: Method get threw exception for reference $templates in template pojo/Pojo.vm at [17,1]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 1:57 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
Okay .. The solution to the exception was to use hibernate3.jar from hibernate-3.1-rc2.

However, still no equals(), hashCode(), and toString() methods.


Top
 Profile  
 
 Post subject: Is hashCode() and equals() required for hibernate 2.1.8 ??
PostPosted: Wed Nov 09, 2005 3:14 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
I went back to Hibernate 2.1.8, and simply ran ant from the command line to generate Java from hbm.xml files. Now I have the toString() method.

But still no hashCode() and equals() method.

Then I noticed in the ChangeLogs:

Changes in version 3.0 beta 1 (21.12.2004)
------------------------------------------
* Hibernate now much more robust if user does not implement equals()/hashCode() on id and unique key classes

Changes in version 3.0 beta 3 (30.1.2005)
------------------------------------------
* it is no longer truly necessary for composite identifier classes to implement equals()/hashCode() (but still recommended)


However, these are with Hibernate 3.0.
Are these statements also true for 2.1.8 ??


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:18 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
In Hibernate Tools 2.x you can include several meta tags to control the creation of equals/hashCode, and the contents of those methods. It is documented in section 15.2.2 of the Hibernate 2.x manual:

http://www.hibernate.org/hib_docs/reference/en/html/toolsetguide.html#toolsetguide-s2-2

I have not tried the same meta tags in tools 3.x, but there is code to handle them. It looks (from code) like 3.x is smarter and has dropped the implement-equals meta tag, and instead will automatically implement equals/hashcode if any use-in-equals meta tags exist on a class's properties.

Hope that helps?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:20 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
I didn't mention it, but there is also the use-in-tostring meta tag that is also still handled in 3.x tools.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 11:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, put the meta tags in there and you will get equals,hashcode etc as you want them.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 7:26 pm 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
Thanks for all of that. My confusion was that the O'Reilly book I was reading shows that hbm2java was supposed to generate hashCode() and equals() automatically. So I was wondering why it was not generated for me.

Anyway, I found this in the release notes for 2.x:

Changes in version 2.1.1
------------------------

* added support for generating empty concrete class for a Base class.
* added support for <parent> in <composite-element>
* added meta class-code, extra-import attributes
* hbm2java no longer generates automatically an equals()/hashcode() set unless the class has a composite id or the class is a composite.
- use meta implement-equals attribute to enable generating equals()/hashcode() + mark relevant properties with meta use-in-equals attribute.
* added meta use-in-equals attribute.


So I presume hashCode() and equals() is really ONLY NEEDED for composite ids ? ... even in Hibernate 2.x ?

Basically, do I still need to or not ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 1:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, equals and hashcode is equally important but it was realized that generating them automatically without user definition were unsafe. See http://www.hibernate.org/109.html.

Note, we do now support an automatic generation when you have a <natural-id> but we dont reverse engineer that (yet)

_________________
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.  [ 9 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.