This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Problems with using property in formula [hibernate] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problems with using property in formula [hibernate]" Watch "Problems with using property in formula [hibernate]" New topic
Author

Problems with using property in formula [hibernate]

Sergey Shantor
Greenhorn

Joined: Jan 19, 2010
Posts: 3
I have many-to-many relationship:

COMPANY * - * EMPLOYEE

here is CompanyDTO (POJO):



and also сompanyDTO.hbm.xml :



the question is next- how can I use the employee_id from the related table, to get the proper meaning from table "position", that consist of (company_id[Long], employee_id[Long]) - individual for each [employee 1 - 1 company]

private EmployeeDTO employee is already set for necessary Employee meaning


[Thumbnail for structure.JPG]

Sergey Shantor
Greenhorn

Joined: Jan 19, 2010
Posts: 3
solved with

<join table="COMP_EMPL" inverse="true" optional="true">
<key column="company_id" />
<many-to-one name="employee" column="employee_id"
not-null="true" />

<property name="position" type="string">

<formula>position</formula>
</property>


</join>
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Wow, what a thorough post! Very impressive for a Greenhorn. And thanks for posting back an answer. That's the spirit of giving.

I sent you a private message, so feel free to check your private messages on JavaRanch.

Kindest regards,

-Cameron
 
GeeCON Prague 2014
 
subject: Problems with using property in formula [hibernate]