-->
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: Mapping new and existing data together
PostPosted: Wed Apr 13, 2011 4:08 am 
Newbie

Joined: Wed Apr 13, 2011 3:36 am
Posts: 1
Location: UK
Forgive the newbie question. I've searched and searched and not found the answer I'm looking for. Or rather I've found several answers and none of them seem to work for my particular use case.

I am trying to map some TV show data from an existing website, with an existing java API into Hibernate.
There are some oddities to the data which I know how I would program around, but I feel sure that Hibernate should be able to cope with. I'll explain the models (reduced for simplicity's sake, but they can be found HERE)

There are three classes I'm currently interested in:
Series (Holds info on the TV series)
Code:
public class Series {
    private String id;
    private String seriesName;
    private List<Person> actors = new ArrayList<Person>();
    // Getters & Setters
}


Episode (Holds information on individual episodes)
Code:
public class Episode {
    private String id;
    private int seasonNumber;
    private int episodeNumber;
    private String episodeName;
    private List<String> directors = new ArrayList<String>();
    private List<String> guestStars = new ArrayList<String>();
    // Getters & setters
}


Person (Holds information on cast members, but I also want to add in directories, writers, etc)
Code:
public class Person implements Comparable<Person> {
    private long id;
    private String name;
    private String job;
    private String role;
    // Getters & Setters
}


So the relationships are:
Series 1:M Episode (A Series has many Episode)
Series M:M Person (A Series can have many Person, a Person can be in many Series)
Episode M:M Person (An Episode can have many Person, a Person can be in many Episode)

Side note:
I'd like to try and not create specific attributes of the models for Hibernate and use JPA if possible. I saw some solutions that advised adding a "List<Series> series" to each person, but that would not be possible to populate from the source site and would mean nothing to people who use the API without hibernate.

So, the first complication:
Each series has a list of actors, they do have a UID with them, but that is specific to the site I'm gathering data from, so I'd like to create my own UID. So when I save the series record, I need to look that up and reference the existing record if there, otherwise it should be created.

Can this be done (easily?) using JPA?
I know how I would do it with code, but how do I maintain the relationship with the

Second complication
The episode person information, held in the "directors" and "guestStars" fields, need to be merged into the Person table.
I can create the records easily, but how do I create the associate between the Episode and "new" Person record?

Is it a case of manually maintaining a "Episode_Person" table?

Thanks for any insight or pointers you might give to a newbie. I feel if I can crack this, the rest should fall into place.

Stuart


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.