-->
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: Composite keys with @manytoone in them
PostPosted: Sat Feb 09, 2008 6:38 pm 
Newbie

Joined: Sat Feb 09, 2008 6:25 pm
Posts: 3
Hi , is it possbile in hibernate to have the following mapping ? :

Code:
public class OptionIntra
   implements Serializable{

   private static final long serialVersionUID = 1L;
   
   private StockExchange stockExchange;
   private OptionType optionType;
   private int strike;
   private PaperEod paperEod;
   private Date expirationDate;
   private int daysTillExpiration;
   private String optionDesc;
   private Timestamp timestamp;
   private double fairValue;
   private int transactionsNumber;
   private double transactionMoneySum;
   private double price;
   
   @Id
   @Enumerated(EnumType.STRING)
   @Column(name="stockexchange",nullable=false)
   public StockExchange getStockExchange() {return stockExchange;}
   public void setStockExchange(StockExchange stockExchange) {this.stockExchange = stockExchange;}
   
   @Id
   @Enumerated(EnumType.STRING)
   @Column(name="optiontype",nullable=false)
   public OptionType getOptionType() {return optionType;}
   public void setOptionType(OptionType optionType) {this.optionType = optionType;}
   
   @Id
   @Column(name="strike",nullable=false)
   public int getStrike() {return strike;}
   public void setStrike(int strike) {this.strike = strike;}
   
   @Id
   @ManyToOne(fetch=FetchType.LAZY)
   @JoinColumns({
      @JoinColumn(name="paper_date",nullable=false),
      @JoinColumn(name="paper_name",nullable=false),
      @JoinColumn(name="paper_id",nullable=false)
      }
   )
   public PaperEod getPaperEod() {return paperEod;}
   public void setPaperEod(PaperEod paperEod) {this.paperEod = paperEod;}


it's seems to me like a very common thing to have inside an application yet i can't ge it to work with idclass/embeded ?
i tried using the
Code:
<property name="hbm2ddl.auto">update</property>

just to see how hibernate will treat this i get :
BLOB/TEXT column 'paperEod' used in key specification without a key length , and when i try to trick it by defining the columns that refer to PaperEod and map the relathiontip with the IdClass i get String or byte will be trunced ...
i saw hbm has a key-many-to-one but can't find an annotation for it ?
thanks


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.