-->
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.  [ 3 posts ] 
Author Message
 Post subject: composite-id && session.get
PostPosted: Fri Oct 06, 2006 3:20 am 
Newbie

Joined: Tue Jun 27, 2006 9:34 am
Posts: 9
Location: St. Petersburg
what do i need to place in session.get(class, serializable) when my serializable consists of two integer?


Mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
  <class name="com.Elcom.tables.Contacts.OrganisationContact" table="OrganisationContacts">
    <composite-id>
      <key-property name="person" type="integer" column="person_id"/>
      <key-property name="organisation" type="integer" column="org_id"/>
    </composite-id>
    <many-to-one name="person" class="com.Elcom.tables.Contacts.Person" insert="false" update="false">
      <column name="person_id"/>
    </many-to-one>
    <many-to-one name="organisation" class="com.Elcom.tables.Organisation" column="org_id" insert="false" update="false"/>
    <property name="job" type="string" length="50"/>
  </class>
</hibernate-mapping>


I need function with interface:
Code:
OrganisationContact getOrganisatonContactById(Long org_id, Long person_id)


Should I use HQL query? Or I can use session.get somehow?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 06, 2006 4:08 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
From Hibernate reference doc: -

"Unfortunately, this approach to composite identifiers means that a persistent object is its own identifier. There is no convenient "handle" other than the object itself. You must instantiate an instance of the persistent class itself and populate its identifier properties before you can load() the persistent state associated with a composite key. We call this approach an embedded composite identifier, and discourage it for serious applications. "


So that means that you'll have to do something like:

OrganisationContact organisationContact = new OrganisationContact();
organisationContact.setPerson(....);
organisationContact.setOrganisation(...)

and then use this object in session.get


Top
 Profile  
 
 Post subject: finding the same error
PostPosted: Thu Oct 19, 2006 8:49 am 
Newbie

Joined: Tue Jun 20, 2006 3:01 am
Posts: 4
i am doing the same with setting the properties but its giving me the error
org.hibernate.MappingException: Unknown entity: com.ess.sing.mvi.md.hibernate.system.gui.GuiFormTabsId

in my case i am having 2 properties in my PrimaryKeyClass formName and the tabIndex


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