-->
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: Jointablemapping+intermediate entity: composite-id question
PostPosted: Mon Jun 27, 2011 5:20 am 
Newbie

Joined: Mon Jun 27, 2011 4:55 am
Posts: 2
Hello,

im using an intermediate entity class to map additional columns to a jointable and it works fine as long as the Id will be generated from the both ids from the involved tables.

Now i need to add a third value from the entity-class to the composite-id, because i want to generate objects with new Ids out of the existing ones.

I want to add the integer-value "revision" from BacklogAufgabe to the composite-id.
With this mapping the error: "An association from the table backlogaufgabe refers to an unmapped class: int" occurs, i understand it, but i cant find a solution to properly map this correctly.

Here s the mapping + sql:

Code:
<hibernate-mapping package="app.domain">
  <class mutable="false" name="app.domain.BacklogAufgabe" table="backlogaufgabe">
    <composite-id class="BacklogAufgabe$Id" name="id">
      <key-property access="field" column="id_backlog" name="backlogId"/>
      <key-property access="field" column="id_aufgabe" name="aufgabeId"/>
      <key-property access="field" column="revision" name="revisionId"/>
    </composite-id>

    <property column="datum" name="datum" not-null="true" type="date"/>
    <property column="rang" name="rang" not-null="true" type="int"/>
    <property column="revision" name="revision" not-null="true" type="int"/>
    <property column="aufw_schaetzung" name="aufwSchaetzung" not-null="true" type="int"/>
    <property column="aufw_messung" name="aufwMessung" not-null="true" type="int"/>

    <many-to-one cascade="save-update" column="id_aufgabe" insert="false" lazy="false" name="aufgabe" not-null="true" update="false"/>
    <many-to-one cascade="save-update" column="id_backlog" insert="false" lazy="false" name="backlog" not-null="true" update="false"/>
    <many-to-one cascade="save-update" column="revision" insert="false" lazy="false" name="revision" not-null="true" update="false"/>
  </class>
</hibernate-mapping>

Code:
CREATE TABLE backlogaufgabe
(
  id serial NOT NULL,
  id_backlog integer NOT NULL,
  id_aufgabe integer NOT NULL,
  revision integer NOT NULL,
  datum date NOT NULL,
  rang integer NOT NULL,
  aufw_schaetzung integer,
  aufw_messung integer,
  CONSTRAINT backlogaufgabe_pkey PRIMARY KEY (id),
  CONSTRAINT backlogaufgabe_id_aufgabe_fkey FOREIGN KEY (id_aufgabe)
      REFERENCES aufgabe (id) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE RESTRICT,
  CONSTRAINT backlogaufgabe_id_backlog_fkey FOREIGN KEY (id_backlog)
      REFERENCES backlog (id) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE RESTRICT
)
WITH (
  OIDS=FALSE
);



I would be gratefull for informations about how to map this, thx.


Top
 Profile  
 
 Post subject: Re: Jointablemapping+intermediate entity: composite-id question
PostPosted: Wed Jun 29, 2011 4:24 am 
Newbie

Joined: Mon Jun 27, 2011 4:55 am
Posts: 2
*bump*


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.