transient « Map « JPA Q&A

1. How to make a mapped field inherited from a superclass transient in JPA?

I have a legacy schema that cannot be changed. I am using a base class for the common features and it contains an embedded object. There is a field that is ...

2. [Hibernate]Merge transient object with childrens

I've some probleme with merge. My update method works in this way:

void update(Parent parent) {
My classes:
Parent {

  Long id;


3. Create a persistent object using a transient one

I have 2 mappings like this:

    <class name="A" table="A">  
        <id name="code" column="aCode" type="integer">  

4. Hibernate: Transient table mapping?

I have a table FILEPERM which declares user permissions on file paths:

id filepath user permission
-- -------- ---- ----------
 1 /abc     12   rw
 2 /def  ...

5. Hibernate's session.update(obj) method makes child objects transient (in parent/child relationship)

I have a parent-/child relationship of folders, which looks like this: A folder can have 0-1 parent folders. A folder can have 0-n child folders (subfolders). Using Hibernate, I call session.update(folder) on these folders. When ...

6. NHibernate transient object exception

I want make an insert in the table EmployeebyProject, when try to insert throw the transient object exception. Table EmployeebyProject : {PK: EmployeeId, PK: ProjectId, DateBegin, DateEnd} This is the mapping:


7. Mapping calculated field from sql-query to transient attribu

String sql = "select *, ( 6371 * acos( cos( radians(latitude) ) * cos( radians( :lat ) ) * cos( radians( :long ) - radians(longitude) ) + sin( radians(latitude) ) * sin( radians( :lat ) ) ) ) as distance" + " from Restaurant res where res.status = 1 and " ...

8. Natural-id and how to save transient children on it

I have a parent-object with some children-objects in an array. I have defined an natural-id on some of the properties of the child, so the children will be unique. Both parent and child have an id-property. When I save the parent some of the children will be transient but in the database already if you look to the natural-id. So if ...

9. Saving transient parent with transient children

Anthony posted this response to a recent question related to mine. I am doing the child.setParent( parent ) and parent.addChild( child ) thing but outside of a session. I expect hibernate to persist the parent first followed with the children but instead I get the "unsaved transient" error. ********************* Transaction trx = session.beginTransaction(); Parent stephen = new Parent(); stephen.setName("Stephen Earl");; ...

10. Mapping transient properties

Howdy, I'm using Hibernate 2.1.8, JDK 1.4.2 and Oracle9i. I've been scouring the documentation, tutorials and hibernate action book and can't find a way to do the following. Any suggestions would be appreciated. Let's say I have the following two persistant classes which I can map to the database. With the exception of the companyName field in User. Class: Company - ...

12. Override fields to transient

Hi, I would like to know if it is possible to override a embedded field (and also a parent class field) to turn it transient. The use case is: Code: @MappedSuperclass @Embeddable public class Person { private String name; private Date dateOfBirth; ... @Column(name = "NAME") public String getName() { ...

13. Problem saving Transient Parent and Children at once

Hi there! Im having some problems with the persisting of transient objects with a collection of other transient child objects. Maybe someone has seen this before and can open my eyes. For the introduction, Im using the Spring Framework and Hibernate 3.2 to persist objects with the following relationship. Really basic! Code:

14. Using a mapped object in a transient method?

public class A { private Long id; private String s; private Integer i; private B b; [...] getter and setter @ManyToOne(optional = false, fetch = FetchType.EAGER) public B getB() { return b; } @Transient public ...

15. persistent parent and transient child save

I have parent and child with cascade all . In my case I open session, load the parent create a new child (this is transient) and add this child to parent and call save , I was hoping that hibernate would generate the PK for the newly added child , but it did not , it is generating only after flush ...