-->
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: Oddball mapping of legacy data
PostPosted: Fri Jun 22, 2007 12:05 pm 
Newbie

Joined: Fri May 25, 2007 4:45 pm
Posts: 3
I am pretty new to Hibernate. My agency is converting hundreds of legacy COBOL programs to java. This also leaves us with a fairly ugly legacy database that is slowly being normalized.

We are still having to use the legacy data prior to the normailization.

Here is the problem I am currently facing:

Two entity classes, each with three column keys, but only two of the columns are shared between the classes.

Example of the two embeddable key objects:

@Embeddable
public class FooKey {
private String fred;
private String barney;
private String bamBam;
.
.
.
}

@Embeddable
public class BarKey {
private String fred;
private String barney;
private Integer pebbles;
.
.
.
}


In our real classes each of the fields also have @Column annotations.
What the business logic calls for is that the Foo class contains a collection of Bar objects and that the one to many association use the columns fred and barney for the join. For purposes of the join bamBam and pebbles should be ignored.

I understand that this is an absolutely horrible data design, but I didn't create it! I just have to make it work.

Additionally, we are supposed to try and handle all of the hibernate mappings using annotations, not hbm files.
Anyone have any ideas? I have tried many of the techniques in the book "Java Persistence with Hibernate", but no success. Possibly(probably) I have made mistakes there.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 3:58 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
It should be possible. You will need to declare a unique-key on fred and barney and then when you are referring to the other class you will need to use "property-ref" attribute.

I am not well versed with annotations, but if you can start with the hbm files and then convert them into annotations then I can help.

I would need to see how you are joining these classes and where are these embedded. Also, what is the table structure.

Regards,
Jitendra
*Don't forget to rate*


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.