Hello!
I am a newbie with Hibernate and I am using the latest version of Hibernate in my Flex/BlazeDS/J2EE project.
Because I use BlazeDS, which does not support Hibernate's Lazy Loading I have to join a table.
I have this example:
There is a ContactGroup which is in a 1:n relation to Contact, So one ContactGroup has many Contacts and one Contact is in one ContactGroup.
In class Contact.java there is not an annotation like "mappedBy", "ManyToOne", ...
In class ContactGroup.java, there is
Code:
@OneToMany(fetch=FetchType.EAGER)
@Cascade({org.hibernate.annotations.CascadeType.ALL})
@JoinTable(name="Group_Contact",joinColumns=
{
@JoinColumn(name="groupId")
}
)
@Fetch(FetchMode.SUBSELECT)
private List<Contact> m_contacts;
public List<Contact> getContacts()
{
if (m_contacts == null)
m_contacts = new ArrayList<Contact>();
return m_contacts;
}
public void setContacts(List<Contact> contacts) { m_contacts = contacts; }
Here I do not understand what is done exactly. A table between Contact and ContactGroup called "Group_Contact" will be created (I only need this table,
because of the non supported Lazy Loading of BlazeDS (I know that I can solve this, using Frameworks like Cairngorm, or Spring, but I do not want to use them, because I am a newbie and
I have problems to understand Hibernate, and I do not want to use x other Frameworks, which I will also a newbie in and there will be other problems)).
In this table, there must be the ID of the Group and the ID of the Contact, right?
Now it is possible to get all Contacts from the class ContactGroup. But how can I get from a Contact the linked ContactGroup? I do not see that this is bidirectional, because in Contact.java, there is no attribute like
private ContactGroup theContactGroup;
How can I get this bidirection in my case?
Best Regards and thanks a lot in advance, PHANTOMIAS