Hello Hibernate folk,
I'm new to Hibernate, and I've got a slightly complicated situation to map to Java objects, from a legacy Oracle database.
server -> service -> location
The foreign key from server to service is a composite (id, ser_code). From service to location is just id.
I need to build from this an object that will give me a server at a given country. Worst case, I could add a new view to the database, doing a join across the tables in SQL, and mapping the view to an object, but being legacy, this isn't the best option.
I thought about using the hibernate keyword "join" to get the same effect as with a view (we're defining our objects in XML by the way), but it seems I can only do that for 1-1 relations? Does anyone know why that is? Here there can be multiple servers at a given service/location, which would rule out this approach.
I also thought I could use the many-to-one style, but that means creating 3 Hibernate objects, which I thought might be less efficient and doesn't look as nice.
Failing that, I understand I could also do something with HQL, but that sounds pretty advanced.
Any advice here about the way to go would be fantastic.
Many thanks!
|