java - Hibernate: Specifying columns in a one-to-many relationship -


I am trying to create a layer of hibernation for a database schema I do not necessarily have any control I have simplified, two tables.

There are two important columns for the table original :

  • parent_id integer primary key Autoincremented
  • parent_code , string, unique key generated by any black box somewhere (assuming it is a UUID for discretion)
  • Data columns

The table contains two important columns of children :

  • Child_parent_id , integer, primary key, autoincremented
  • child_parent_code , foreign key pointing to the parent parent_code of the parent
  • A group of columns of data plus

I want to be able to call my father. Groups () and want to get a collection of hair objects. But in Hibernation, installation of mapping files seems impossible, searching the child table with the parent_id value ( instead of parent_code ).

In Parent.hbm.xml

  & lt; Set name = "childs" inverse = "true" lazy = "true" table = "child" fetch = "" & gt; & Lt; Key & gt; & Lt; Column name = "child_parent_code" no-null = "true" /> & Lt; / Key & gt; & Lt; One-to-many classes = "foo.bar.Child" /> & Lt; / Set & gt;  child.hbm.xml  in  

   & Lt; / Many-to-one & gt;  

I've spent an hour with my copy of keeping Java with my copy, but I do not understand what I want to do I am Is this possible?

Do something like this in the parent:

  & lt; Set name = "hair" inverse = "true" lazy = "true" table = "child" bring = "select" & gt; & Lt; Key column = "child_parent_code" property-riff = "code" /> & Lt; One-to-many classes = "foo.bar.Child" /> & Lt; / Set & gt;  

And in this child:

  & lt; Many-to-one names = "parent" class = "foo.bar.Parent" fetch = "select" column = "child_parent_code" property-riff = "code" />  

I assume that the code property in the original is called "code".


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -