object « Association « JPA Q&A





1. Hibernate: How declare foreign key without having to code association methods in the domain object?    stackoverflow.com

I have two related tables, MANY and ONE. An integer ONE_ID column on the MANY table formalises a many-to-one relationship. I want to map to Many and One domain objects and to ...

2. Hibernate Criteria one to many association, mutiple objects    stackoverflow.com

public class Company{

    private Long id;
    private String companyName;
    private List<Employee> employees;

}

public class Employee{

    private Long empid;
   ...

3. two one to many associations that point to the same object    forum.hibernate.org

i'm using hibernate as my JPA layer. I want to be able to do: user.getSentMessages() and user.getReceivedMessages() where both of those would be hitting the Messages object. The messages object would have sender and receiver properties. Is it possible/advisable to map an association like this? How would you do it using JPA annotations?

4. many-to-one value object association    forum.hibernate.org

5. retrieving an object with associations    forum.hibernate.org

I don't understand why this code retrieve only one document from the category: public void execute() { Transaction tx = null; Category category = null; try { int categoryID = 3; Session session = HibernateUtil.currentSession(); tx = session.beginTransaction(); category = (Category) session.get(Category.class, new Long(categoryID)); Hibernate.initialize(category.getDocuments()); tx.commit(); } catch (HibernateException he) { try { tx.rollback(); } catch (HibernateException he2) { he2.printStackTrace(); } ...

6. Simple Retreating Objects with Join Association Question!    forum.hibernate.org

Author Message Kevin_L Post subject: Simple Retreating Objects with Join Association Question! Posted: Fri Apr 29, 2005 10:55 am Newbie Joined: Tue Jan 11, 2005 11:30 pm Posts: 3 Hi Everyone, I appreciate it much if someone could help me out. This is the basic simple step of retreating objects by join association. I have search through the website ...

7. Associations without recreating entire object?    forum.hibernate.org

Hi, Is it possible to have an association between entity objects such that when I read that association back out of the database it will provide me with just the identifier of an entity object on the end of an association rather than the whole entity object? i.e. in the mapping below, when I get Activity's flow property it will be ...

8. Detach an object related with a many-to-one association ?    forum.hibernate.org

Newbie Joined: Fri Oct 28, 2005 9:08 am Posts: 12 I have a many-to-one association. When I get the first object, I evict it from the session (I use session.clear() to evict all objects). Because I set lazy="no-proxy" for the association, the object associated is not loaded. I want to use my service to populate the associated object but I have ...

9. Object-Deletion in an one-to-one association    forum.hibernate.org

Hi, I'm new with hibernate and have a question about deletion in a one-to-one association. I have a class Person that has one-to-one association to the company the person works for. @Entity @AccessType(value = "property") public class Person extends PersistentObject { protected Company company; @OneToOne(cascade = CascadeType.ALL) public Company getCompany() { return company; } public void setCompany(Company company) { this.company = ...





11. Why does the moved object still exsit in the association?    forum.hibernate.org

A conference has many calls. The following codes move a call (id:6578) from one conference (id:6821) to another conference(id:7474). Code: @Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT) public void moveCall(String command) { String[] args = command.split( " " ) ; long callid = Long.valueOf( args[1] ) ; ...

13. Retrieving and object with its associations    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3+ Mapping documents: ...

14. Prob - UserType and objects having an association to itself    forum.hibernate.org

Author Message bergnerjoerg Post subject: Prob - UserType and objects having an association to itself Posted: Wed Apr 02, 2008 4:29 am Newbie Joined: Mon May 30, 2005 5:42 pm Posts: 2 Hello! First the facts: Hibernate version: 3.2.6.ga Mapping documents: Code:

16. Hierarchic Object Associations    forum.hibernate.org

Hello everybody: I have the following classes: LogActivity <-- Comment (LogActivity mother of comment) Model In addition a model contains a reference to a set of comments and each LogActivity is about (one-to-one) a model. In practice the Hibernate mapping files are: Code: > ...