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: need help with composite id Nhibernate
PostPosted: Mon Aug 21, 2006 8:51 am 
Newbie

Joined: Mon Aug 21, 2006 8:33 am
Posts: 3
I have a problem to insert a composite-id object into Mysql database
The problem is that before inserting a new object into database I should verify if the object already exist or no
I tried to use Isession.get() but I don't know which identifier should I enter
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" auto-import="true" >
<class name="FlatInfo.DataCollector.Service,FlatInfo.DataCollector" table="Service" lazy="true" mutable="true">
   <composite-id>
      <key-property name="ServiceName" type="System.String"/>
      <key-property name="Version" type="System.String"/>             
   </composite-id>
   
</class>
</hibernate-mapping>

or should i change the mapping file and manage to have an auto generated id

Please is there any one to help it is urgent!!!!!
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 4:34 pm 
Newbie

Joined: Mon Aug 07, 2006 6:40 pm
Posts: 12
Location: Atlanta, GA
Without seeing your code:

[1]You need to create a class (it could be nested) that represents the composite key that conforms to NHibernate class design rules for your implementation
[2]Add a property for an object of that class
[3]Add the name="" to the <composite-id> element with name of the property

The Get() method would then accept the class you have added as key object argument

Of course, creating a single identifier of a native type would also address it. Since your composite key is not a native type, you need to provide one.


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.