persist « Map « JPA Q&A





1. JPA/Hibernate mapping to store months and days-of-months    stackoverflow.com

I have following POJOs:

class Month {
    long id;
    String description;
    List<Day> days; // always contains 29, 30 or 31 elements
}

class Day {
 ...

2. Java: Using which database technology could I persist objects? (Something that does NOT require me to take care of mapping objects to tables and back)?    stackoverflow.com

I need to use an object oriented data repository for a project.
It's going to be something between a wiki and a CMS. I'm not an expert in the field of persistence ...

3. Mapping calculated properties with JPA    stackoverflow.com

Is there a way to map a calculated property using JPA? Assuming I have an Invoice object with one or more InvoiceLineItems within it, I want to have a persistent calculated property ...

4. Changing target table for Hibernate mapping    stackoverflow.com

Is it possible to change the target table for a Hibernate mapping? My use case is that while I get the data from one table, in cases where the data cannot ...

5. jpa one-to-many persist children with its ID    stackoverflow.com

@Entity
public class Item {

 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 @Column
 private Long id;
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "item")
 private List<Feature> features= new ArrayList<Feature>();
The Children Entity:
public ...

6. Problem persisting inheritance tree    stackoverflow.com

I have a problem trying to map an inheritance tree. A simplified version of my model is like this:

@MappedSuperclass
@Embeddable
public class BaseEmbedded implements Serializable {

   @Column(name="BE_FIELD")
   private String ...

7. Getting the ID of the persisted child object in a one-to-many relationship    stackoverflow.com

I have two entity classes A and B which looks as follows.

public class A{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;  ...

8. javax.persistence annotations and inheritance    stackoverflow.com

I have 4 persistent classes which all have the same fields (exactly) the only 3 difference between them is 1) the class name, 2) the table name and 3) the data. ...

9. Why isn't Hibernate transitive persistence working?    stackoverflow.com

I have 2 tables in a parent/child relationship in which I am trying to insert records. ParentID is a foreign key in child table, and I have cascade="all" in the parent ...





10. How annotation mapping is done in java persistence?    stackoverflow.com

We use annotations for mapping the entity class with the database table by simply specifying @Entity and more like @Id, table joins and many things. I do not know how these ...

11. Persistence a child object with existing parent one    stackoverflow.com

Assume there are two entities with ManyToOne relation:

@Entity
public class A {
    private long code;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)   
    ...

12. How to delete interrelated objects with Hibernate    stackoverflow.com

I have two object. Let it be company and employee.

CREATE TABLE company (
  company_id BIGINT(20) NOT NULL AUTO_INCREMENT,
  name VARCHAR(255) NOT NULL,
  chief_id BIGINT(20) NOT NULL,
  ...

13. JPA @Entity Inheritance    stackoverflow.com

I have been looking into JPA/Hibernate @Entity inheritance for a while now and can't seem to find anything that addresses what I am trying to achieve. Basically I want to be able ...

14. persisting parent and children, hibernate    stackoverflow.com

i'm having a parent to children mapping with a link table

<hibernate-mapping>
    <class name="BatchOverrideDo" table="Override" catalog="SN01_DB">

        <id name="overrideId" type="int">
   ...

15. Hibernate - How to persist only the parent, keeping the children as they are    stackoverflow.com

Can someone please help me understand how to configure hibernate to do what i want. I have a parent entity "Appartment" with a List of "Room"s as children. I have a form to ...

16. How to persist a class using hibernate which is used in many different ways?    stackoverflow.com

I am new to hibernate world, still learning it. I am trying to persist one class in database using hibernate. Objects of this class can have different meaning in its client ...





17. hibernate 3: tough time retrieving/persisting child objects    coderanch.com

I've read through the documentation but I'm having a tough time understanding the concepts of how to join tables & automatically persist child objects when it comes to related tables. I'm having a particularly hard time getting a simple one-to-one data relationship to end up persisting as two objects. I have a very good understanding of relational databases & table relationships ...

20. Adding a new child to an entity removes the persisted one    forum.hibernate.org

Hi all, I have a simple parent-child relationship: The parent class: Code: @Entity public class Parent implements Serializable { @Id @GeneratedValue @Column(name = "PARENT_ID") public long getId() { return id; } // some other fields @OneToMany(cascade = ...

21. parent child persistence problem    forum.hibernate.org

I have a parent child relationship Parent Entity Child Entity, when I persist the child enity I wish to persist the parent. childEntity.persist() The parent enity id is autogenerated when persisted. As you can guess when I call childEntity.persist() I get the id must be set for the parentEntity, before the childEnity can be persisted. when I call childEnity.persist() I want ...

22. Hibernate tries to PERSIST entities that are not mapped    forum.hibernate.org

Hi everyone, Im currently working on a gef based Gui builder. The information of this builder should be saved in a database using hibernate. If I try to save the model, the following exception is thrown: org.hibernate.type.SerializationException: could not serialize at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:158) at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:178) at org.hibernate.type.SerializableType.toBytes(SerializableType.java:74) at org.hibernate.type.SerializableType.deepCopyNotNull(SerializableType.java:70) at org.hibernate.type.MutableType.deepCopy(MutableType.java:25) at org.hibernate.type.MutableType.replace(MutableType.java:36) at org.hibernate.type.AbstractType.replace(AbstractType.java:153) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:453) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:361) at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:179) at ...

23. problems on persisting the child entity.    forum.hibernate.org

Hi guys, i am facing some problem on saving the child entity together with the parent entity. here is my codition: i have an entity named Employee, and this employee entity is having a list of sub record named WorkExperience. so i once in persist the employee entity, all it's sub records(WorkExperience) will be persist as well. but my problem is, ...

25. Persistence a child object with existing parent one    forum.hibernate.org

Assume thre are two entities with ManyToOne relation: Code: @Entity public class A { private long code; @Id @GeneratedValue(strategy=GenerationType.AUTO) public long getCode() { return code; } public viod setCode(long code) ...

26. Simple question: How to persist child with only parentId?    forum.hibernate.org

I have two classes: Code: Parent: @Entity public class Leilighet { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long leilighetId; private String adresse; private String postNr; private String postSted; @OneToMany @JoinColumn (name = "leilighetId") ...

27. Issue on persistence mapping.ideas needed!!    forum.hibernate.org

Hi guys, Im having some troubles trying to configure a many to many relationship between a class i have just created (Installsupport) and another one called userInfo which as implementation of springframework.security.core.userdetails.. the idea is creating and inbetween table named /Users_InstallSupport) where Installsupport and UserInfo where a given object installSupport is able to get all the Usernames of the users related ...

28. Persisting Maps Containing UTF-8 Characters    forum.hibernate.org

Newbie Joined: Wed Oct 01, 2003 10:52 am Posts: 6 Location: Oslo, Norway I am running into problems trying to persist a map containing various UTf-8 (non-ascii) characters. I have a Map containing String/Integer pairs. When I try to store the map, I get the following SQL exception: Code: (util.JDBCExceptionReporter 38 ...

29. Persisting inner classes with inheritance    forum.hibernate.org

I'm implementing the 'State' pattern from the 'Applied Java Patterns' book, and would like to be able to persist the current state using Hibernate. I've run into troubles because the State pattern dictates that the state classes (one per state) be inner classes of the context object. My context object is also persistant. To simplify, given class A (the context), with ...

30. one table mapped as interface -persisted as impl need sample    forum.hibernate.org

The documentation says It is perfectly acceptable for the named persistent class to be an interface. You would then declare implementing classes of that interface using the element. com.microsoft.northwind.Product is an interface com.microsoft.northwind.impl.ProductImpl is the only implementing class So I try ...

31. Not persisting certain child objects    forum.hibernate.org

Author Message vpuzzella Post subject: Not persisting certain child objects Posted: Tue Feb 24, 2004 6:20 pm Newbie Joined: Tue Feb 24, 2004 10:59 am Posts: 1 Hi All! First off, Versions: Hibernate 2.1.2 and MySQL 3.23.38. I am having a problem where certain child objects are not being persisted. Here is my Java code (Objects I am concerned ...

32. Can Hibernate "persist" objects not mapped to a ta    forum.hibernate.org

Hello and thanx for any help you can offer. As part of an evaluation of Hibernate as a possible component of an application that is being refactored, I have downloaded version 2.1.3 and done some very successful initial testing.This has led me to the details (where the devil is). My question is: Can I map a class that is NOT directly ...

33. Best way to persist inherited domain objects?    forum.hibernate.org

What is the best way to store inherited domain objects? For example, I have a Business object, but there are actually 4 types of businesses. Most of them actually have only 1 field, but one of them has a few extra fields. I figured I could have 5 tables all together, but I'm not really sure how to approach it exactly. ...

35. How to distinguish which child object will be persist    forum.hibernate.org

Hi, I'm looking for help regarding the mapping of classes in the configuration file. I have a master table (promo) which has many child tables (promo_discount_stay, promo_discount ) the structure are below in the mail. I have successfully implemented the requirement to save into promo table and promo_discount_stay (child) table. Now I have to save in a particular child table , ...

36. Controlling whether a child object should be persisted    forum.hibernate.org

Is is possible to explicitly flag an object from a persistent collection not to be persisted with the others in the collection? I have a parent-child relationship where I want to add a new child that must not be persisted with the rest of the children. This alltimes transient child is my proxy to an external data store (maybe a database, ...

38. trouble persisting child object    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp The parent object is persisted but I get an exception on the child object. not-null property references a null or transient value Any help would be greatly appreciated. Scott Hibernate version:2.14 Mapping documents:

39. Persisting multiple new child Objects stored in a Map    forum.hibernate.org

I am storing my associations as Maps. I only saveOrUpdate on the parent Object. I cascade updates. When I want to create a new child Object, I simply put it in the map of the parent Object. The id for the new child Object is set using a database sequence, so I never explicitly set the id of the child Object. ...

40. The usual parent/child problem (cannot persist children)...    forum.hibernate.org

Hello, I know this is the most basic of functions/issues, but I've spent all night on it and am at a loss. I've read the doc and searched the forums. I'm really stuck. Below, you'll see I've modeled a bi-directional relationship from Chapter 7 of the Hibernate documentation as best I could. In this example, all I want to do is ...

41. persisting inherited objects    forum.hibernate.org

42. Children persistent collection management    forum.hibernate.org

I am trying to find out a way to easy manage a children collection within a parent object by adding, removing or changing the entries in a collection a children object referenced by a parent object. Is there a way to make these changes to the children Set persistent? My case is a one to many parent child relationship, with inverse= ...

43. Question about persisting child objects (one-to-many)    forum.hibernate.org

Hello, I have a general question and (based on the answer to that question) a specific question about an issue I'm trying to work out. First question: When you save a brand new parent object which has a set of child objects (one-to-many collection) do you explicitly have to set the foreign key id of the child to match the generated ...

44. persistent class not mapped    forum.hibernate.org

i have the persistent class as follow: public class MCategory implements java.io.Serializable, TableData { Code: // Fields private String category; private String description; // Constructors /** default constructor */ public MCategory() { ...

45. Transitive persistence and map-key-many-to-many    forum.hibernate.org

It does not seem that hibernate will persist transient entities that serve as keys in maps when persisting the map, even with cascade="all." I am new to hibernate, but can find no reference to this behavior in the most recent documentation; is this a bug or intended behavior? Is there a way around it? Relevant info below - Thanks so much ...

46. Mapping two persistent classes to one table    forum.hibernate.org

I've got a database table with many columns (30+) and if I mapped only one class to it i'd be retrieving too much data on each db call. Are there any foreseeable problems with mapping 2 different persistent classes to the same database table? Any other ways of overcoming this? Can you lazy load certain properties or components?

47. Persisting map with persistable key class    forum.hibernate.org

I have a class that can contain properties. Like so Code: class DBNamedObject extends Xxx{ Map properties; public Map getProperties(){ return this.properties; } public String getProperty(DBPropertyType key) { return (String)this.properties.get(key); ...

48. Problems with Persisting Object Relational Mappings    forum.hibernate.org

Hibernate version: 3.1.2 Mapping documents: ...

49. Parent-child Persistence    forum.hibernate.org

Hi.. I am trying to a save a parent-child relationship in Hibernate 3.2 I have created my mappings, DAO & POJO classes using HBT 3.2.8. In the parent mapping xml, I have set child to cascade="save-update". Also all the foreign key mapping in the parent are also set with cascade="save-update". In the child, the parent occurs as a foreign. hence the ...

50. multiple persistent mapping problem    forum.hibernate.org

51. Newbie Persistence Mapping Problem    forum.hibernate.org

Bit of a Hibernate newbie, having problem with some mappings persisting in the database. We have three domain objects subscriber, ips and geodata. Updating these via Hibernate and the three database tables are all persisted. Howoever, the relation between ips and geodata (geo_data_to_ips) is not persisted. No exceptions thrown or any error messages appearing in the log with Hibernate debug on. ...

52. Map Transfer Objects from and to persisted business objects    forum.hibernate.org

I'm trying to figure out how to apply transfer objects in a Hibernate application where there is remote client server communication. Suppose I have an object persisted in the database, a user modifies it and a transfer object with the modified data is returned to the backend, then its not so simple to map this to a business object. For example ...

53. Multiple persistence units with different column mappings    forum.hibernate.org

As the topic implies I want to save one object into two different persistence units. These units/databases have different table layouts therefor I want to somehow define different column-mappings for each of the persistence units (like Customer.name goes into Column "name" in table A and "cust_name" in table B). Any clues how to solve this? Thanks in advance...