retrieve « Map « JPA Q&A





1. Hibernate (JPA) cascade - retrieve id from child    stackoverflow.com

I have a parent class with the following field with cascading option:

public class Parent {
  @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
  @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
  private final Set<Child> children = new ...

2. How to retrieve mapping table name for an entity in JPA in runtime?    stackoverflow.com

Is it possible to determine the native table name of an entity? If Table annotation is present it's easy:

entityClass.getAnnotation(Table.class).name()
But is it possible to get the table name, if no Table annotation is ...

3. JPA to retrieve name-value from child table without using model for child    stackoverflow.com

This is something I'd really like to be able to do - resolve names based on id values without fetching the whole child model. Here is an example of what I have, ...

4. How can I retrieve the foreign key from a JPA ManyToOne mapping without hitting the target table?    stackoverflow.com

I have the following two annotated classes that I use to build a graph:

@Entity
@Table(name = "Edge")
public class Edge
{
    /* some code omitted for brevity */

    ...

5. JPA - single table inheritance with discriminator inserts but fails to retrieve correct object    stackoverflow.com

I have two tables 'Task' and 'Contents'. Im using single table inheritance with discriminator to map two entities (PrimaryContent, AttachmentContent) to the 'Contents' table. I have a parent entity Task that ...

6. How to retrieve value of Releation Table's column    stackoverflow.com

i am new to hibernate. currently i am stuck in one problem.
i have no idea how to retrieve the value of relation table column.

senario:
i have three tables.
TableA:
-------
a_id
a_col1

TableB:
-------
b_id
b_col1

TableC
-------
c_id
a_id
b_id
c_col1
i have created model ...

7. manytomany retrieve Criteria    stackoverflow.com

I have @manytomany relation in hibernate Like : Table Employee

public class Employee implements Serializable {
    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.SELECT)
    @JoinTable(name = "employee_role", joinColumns ...

8. Unable to retrieve the value from grand Child in Hibernate    coderanch.com

I have a table called Parent which has one to many relataion with another table CHILD. This CHILD table has one to one relation with GRANDCHILD. I have used generic names to make my problem more clear. I have a set defined in child.hbm.xml to fetch grandchild ...





10. Retrieve collection child from a parent    forum.hibernate.org

11. Retrieve collection child from a parent    forum.hibernate.org

12. retrieve field length of db column mapped to property    forum.hibernate.org

Hi folks! With MS SQLServer and the JSQLConnect driver (not sure about other db/driver combos) if a string property of an entity has been set with a value longer than the field in the database, it can not be saved. I'd would like to truncate the String to the length of the db column. Unfortunately i couldn't find any way in ...

13. Problem of retrieve parent from child    forum.hibernate.org

I confuse when i try to retrieve parent from child using hibernate. In my case, i using RCP to do interface design and session bean do business logic processing (like save data, retrieve date ...). I got a EJBInvoker as middleman between my user interface and session bean. If retrieve a parent, anything run properly and i also got the child ...

15. Inheritance retrieve only superclass object    forum.hibernate.org

Hi I have a small tree structure database with inheritance. I decided to use the "table per subclass mapping strategy" (see mapping below). In the top level is class TmpC, and it has two subclasses: TmpD, TmpE. One register in table TmpC has a correspondence with one register in TmpD or with one register in TmpE, but not both. Then, in ...

16. Must I retrieve 1000 children to save child number 1001?    forum.hibernate.org

Hello, I'm working with EMF models persisted using Elver/Teneo and Hibernate 3.1.3. My core problem is: Given a Parent entity with a lazily fetched one-to-many "children" association to some Child object: Say I map the children as a list. Say one Parent has 1000 children. If I do Parent.getChildren().add(newChild) and persist. Then Parent.getChildren() will retrieve all 1000 children FIRST, and then ...





17. could not retrieve snapshot: [com.sen.Child#0]    forum.hibernate.org

Hi, I am new to Hibernate. I am trying to implement Uni-directional mappings by using two class Parent and Child. package com.sen; import java.util.Set; package com.sen; import java.util.Set; public class Parent { private long id; private Set Children; public Set getChildren() {return Children;} public void setChildren(Set children) { Children = children;} public long getId() {return id; } public void setId(long id) ...

18. Retrieve System properties in hibernate mapping files    forum.hibernate.org

I have a hibernate mapping file which contains a custom view I need. The problem is I need to be able to put a schema inside my query. The schema is stored inside a system property. Now I know inside of Jboss, I can access my system properties by using ${my.property}, is there something I can do similar to this in ...

19. Retrieve all rows that have children in some other table    forum.hibernate.org

Hi guys, I am quite new to hibernate and I have a question. Lets suppose we have two mappings. One for a Parent table and one for a Children table (with a 1-M relationship). I would like to retrieve all parents that have children but in a very optimized way. Is there any way to do so? Thanks in advance.

20. HQL to retrieve a parent fetching only 1 of its children    forum.hibernate.org

I am having difficulties creating a HQL query to retrieve a Parent object and fetching only one child from its set of children via an outer join. The join condition is to retieve the child given its database id. I have noticed in the documentation that you can add join conditions via 'with' but it rejects asking for a filter. Thank ...

21. How to retrieve only certain child elements in a collection?    forum.hibernate.org

Hi Guys, Sorry if this is a really obvious question. I've been through the docs and have the Java Persistence with Hibernate book, but can't seem to find a simple way of doing what I need. Basically I have a class AccomType, which has a collection of Room objects. I want to retrieve all my AccomType's and their associated Room objects, ...

22. How to use HQL to retrieve a ManyToMany mapping ?    forum.hibernate.org

@ManyToMany @JoinTable(name = "biz_rwd_jn", joinColumns = {@JoinColumn(name = "rwdSch_id")}, inverseJoinColumns = {@JoinColumn(name = "business_id")} ) public List getBusiness() { return business; } ...

23. Error retrieve: Unable to map the database table.    forum.hibernate.org

Newbie Joined: Sun Mar 08, 2009 4:33 am Posts: 2 Greetings, i'm using the Hibernate with Spring framework for my school project. I'm able to use the hibernate to enter data into the database. The snippet of the codes are shown below for inserting records into the database: Code: DataBean dataBean = new DataBean(); dataBean.setDteSent(aujourd_hui); dataBean.setStatut(emauxStatus); getHibernateTemplate().save(dataBean); I want to retrieve ...

24. Retrieve Child without Parent but with Parent ID    forum.hibernate.org

Hibernate version:3.3.1.GA Hello, I have a classical relation Parent - Child, let's say for example Person - Picture and 2 problems related to this situation :). Code: public class Person { private Picture picture; public Picture getPicture() { return picture; ...