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.  [ 1 post ] 
Author Message
 Post subject: @SecondaryTable, secondarytable data does not get persisted
PostPosted: Wed Jan 05, 2011 7:10 am 
Newbie

Joined: Wed Jan 05, 2011 7:05 am
Posts: 1
hi there, i m currently trying to map 2 table to one class using the hibernate annotation "@SecondaryTable":

Code:
@Entity
@Table(name="entityrevision")
@SecondaryTable(name="productrevision", pkJoinColumns= {
      @PrimaryKeyJoinColumn(name="ent_id", referencedColumnName="ent_id"),
      @PrimaryKeyJoinColumn(name="rev", referencedColumnName="rev")}
)
public class Product implements Serializable  {
   private Long _id = null;
   private String _title;
   private Integer _revisionNumber = null;
   private String _imageURL;

   @Id
   @Column(name="ent_id")
   public Long getId() {
      return _id;
   }

   @Id
   @Column(name="rev")
   public Integer getRevisionNumber() {
      return _revisionNumber;
   }

   @Column(name="title")
   public String getTitle() {
      return _title;
   }
   @SuppressWarnings("unused")
   private void setTitle(String title) {
      this._title = title;
   }

   @Column(table="productrevision", name="imageurl")
   public String getImageURL() {
      return _imageURL;
   }
   @SuppressWarnings("unused")
   private void setImageURL(String imageURL) {
      _imageURL = imageURL;
   }
}

CREATE TABLE entityRevision (
   ent_id BIGINT NOT NULL,
   rev INTEGER NOT NULL,

   title varchar(255) NOT NULL,

   PRIMARY KEY (ent_id, rev),
);

CREATE TABLE productRevision (
   ent_id BIGINT NOT NULL,
   rev INTEGER NOT NULL,

   imageUrl varchar(100) NULL,

   PRIMARY KEY (ent_id, rev),
   FOREIGN KEY (ent_id, rev) REFERENCES entityRevision(ent_id, rev),
);


the problem is that i can load but not persist any created products so that it appears in both tables, i.e. data gets stored to "entityrevision" but not to "productrevision"
hibernate logging for persisting a product is:
Quote:
Hibernate: insert into entityrevision (created_at, title, rev, ent_id) values (?, ?, ?, ?))

this is clearly missing "insert into productrevision ..."

does anybody know what i m doing wrong, all related tutorials i have seen work this way


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.