Anil Suvarthan

Greenhorn
+ Follow
since Aug 15, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anil Suvarthan

This is in continuation with the post.

I have a criteria on the object having manytoone relationship with other table which has one discriminator column.

How can i specify a condition in criteria based on the discriminator column of the parent table.

Regards,
Anil
I may have put it in the wrong way.

The values of the table looks like

id name subject Department
------------------------------------------------------
1 Amit Chemistry --
2 Mark Organic Chemi 1 (Chemistry subject row id)
3 Sunil Inorganic Chemi 1 (chemistry subject row id)

When i query the table with name="Amit" the return object shud look like

Employee
--------
id = 1
name = Amit
subject = Chemistry
List<Employee> employees = {new Employee(2, Mark, Organic Chemi)}, {new Employee(3, Sunil, Inorganic Chemi)} - Size 2

Can somebody help me with the mapping to be given .. I am using Annotations

Regards,
AK
Table:
------
id, name, subject, department.

Employee.java:
--------------
id(Column=id), name(column=name), subject(column=subject), List<Employee> (Mapping to department which returns list of employees from that department)

when i get the employee details based on the subject, it shud return the id, name, subject and list of other employees in that department.

We are using annotations. Can somebody help me with the mapping that needs to be given for the List<Employee> which is mapping to department.

Is it possible this way to return a list of the same objects?

Regards,
AK
I have updated the names.

And i've got this one working, it was an issue with the other field which was being updated which is not intended.

Thanks.
Hi,

I found this group to be very helpful with the issues i have got earlier.
Currently we are using Hibernate with Annotations. I am having a problem inserting the rows into a mapping table.

Tables:
Person(PersonId, PersonName)
Dept(DeptId, DeptName, personCreated)
PersonDept(PersonId, DeptId)

In Dept.java I have a mapping defined to retrieve the persons of that Dept.

@ManyToMany
@JoinTable( name="PersonDept"
joinColumns={@JoinColumn(name="DeptId")},
inverseJoinColumns={@JoinColumn(name="PersonId")}
)
public List<Person> findPersons() {
return persons;
}

I am trying to save a new Dept(in Dept table) with existing users to be assigned to the Dept (in PersonDept table).

When i set the values to the Dept class and save the class, it is giving the exception

org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: Person

I have given the cascade option @ManyToMany(cascade=CascadeType.PERSIST), but from the query i got to know that it is trying to save the Person which is not what i am expecting. I want to save a new Dept in the Dept table and the mappings in the PersonDept table with the personIds against the DeptId.

Can anyone help me out with this?

Regards,
Vasanth