-->
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: Tricky DB schema to java object question
PostPosted: Tue Jul 02, 2013 6:59 am 
Newbie

Joined: Tue Jul 02, 2013 6:34 am
Posts: 1
Hi, I am a new hibernate user, and am tasked with adding spring and hibernate to some existing data. I am really not sure how to about it. The table data is structured similarly to the following:
Code:
DATE(PK)       TYPE(PK)    VALUE
01.01.2012     A           hello
01.01.2012     B           world
02.01.2012     A           hi
02.01.2012     B           there


Giving 2 objects as follows:
Object 1: {DATE=01.01.2012; A="hello";B="world"}
Object 2: {DATE=02.01.2012;A="hi";B="there"}

How would this be modelled as a persistent java class? I understand how it would be done if the table had DATE, A and B columns, but am too new to hibernate to know how to resolve this. I envision the class would look like the following:

Code:
@Entity // would this be an Entity type of object??
@Table(name="MyTable")
public MyObject {
   @Id
   @Column(name="DATE")
   private Date date;

   @Column(name="VALUE") // is there some annotation or construct like: where Column(name="TYPE)="A"
   private String a;

   @Column(name="VALUE") // as above
   private String b;

   ...other code...
}


Do I need to make some sort of mapping class or xml file to make this work?

Any help would be appreciated.


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.