File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with using property in formula [hibernate]
 
Similar Threads
Mapping a Join Table with Additional Columns
Hibernate one-to-many weirdness...
One to One mapping in Hibernate 3
Different Mapping Types in Hibernate
Hibernate problem: One-To-Many association