File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes adding id members  to various classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "adding id members  to various classes" Watch "adding id members  to various classes" New topic

adding id members to various classes

Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hi there,

i have a bunch of different objects, all of them auto-generated from an xml-scheme. to give you an example:

i need to get those objects persistent into the database. even though i want to use an ORM tool, prefarable iBATIS, the data needs to be relational accessible via pure SQL. this lead to a data-base design like this:

(without this requirement, the schema would be pretty much the same i guess ;-) )

and here is my problem:

as i dont have influence on the classes i need to persist, they don't have id values. as already mentioned, they are JAXB-generated from an xml scheme. but for persistence with 1:1 and 1:n relations, unique persistant ids are an absolute must.

every single ORM example i find in the web comes with it's objects having id fields, making them perfectly identifiable.

so, where do i get my id's from?

i don't consider this an ORM question, pls dont move. i'd rather put my question like this - what would be the best aproach to get the id to the objects?

(1) changing the classes
hm, i have hundreds of those

(2) wrapping it somehow
how would "somehow" work with so many different classes? effectiveness and performance is a must. am i blind or is the solution non-trivial?

(3) influence on jaxb to generate id's
i'll investigate in this direction

any ideas welcomed!

many thanks,
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
... i solved the problem with extending all schema-derived classes from one common superclass which provides ids ...
I agree. Here's the link:
subject: adding id members to various classes
It's not a secret anymore!