glassfish « Map « JPA Q&A

1. copy child collection to another object

I have a one-to-many relationship between Part and Params (a "Part" has many "Params). I'm trying to do something naive like this:

Part sourcePart = em.find(Part.class, partIdSource);
Part destPart = em.find(Part.class, partIdDest);

Collection<Param> paramListSource = ...

2. Using Eclipselink history policy with inheritance type join

I would like to use eclipse link history to mirror the following to classes

@Inheritance(strategy= InheritanceType.JOINED)
@TableGenerator(name="Employee_Gen", table="ID_GEN", pkColumnName="GEN_NAME", valueColumnName="GEN_VAL", pkColumnValue="Employee_Gen")
public class Employee implements Serializable {

public class CommesionEmployee extends Employee {

3. JPA with Map Collection

5. JPA/Topling Single Table Inheritance issue

@Table(name = "JCTERRITORYSET")
@Inheritance(strategy = javax.persistence.InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "generated", discriminatorType = DiscriminatorType.INTEGER, length = 1)
public abstract class TerritorySet implements Serializable {

@Column(name = "JCTERRITORYSETKEY", nullable = false)
private Integer territorySetKey;

@Column(name = "GENERATED", nullable = false)
private short generated;

@JoinColumn(name = "JCTERRITORYKEY", referencedColumnName = "JCTERRITORYKEY")

6. [JPA] Join with inheritance

7. Enumeration mapping JPA

In our database we have an enumeration of strings. All these strings are actually numbers, for example ['-2', '-1' ,'1' ,'2']. At first I wanted to create an enumerator in Java for this but I couldn't find out how to do it, since enumerated values cannot start with a number. Then I thought that I could use an int in my ...

8. JPA mapping file

9. JPA - ManyToMany deletes to much

On Nov 22, 2007 12:09 PM, wrote: > i have a temporary fix that first checks all the childs (recursively) > > public void deleteNodesWithMainId(@WebParam(name = "main_id") Integer mainId) { > deleteNode(em.find(Node.class, mainId)); > } > > private void deleteNode(Node n) { > Iterator it = n.getChildNodes().iterator(); > while(it.hasNext()) { > Node nChild =; > if(nChild.getParentNodes().size() == 1) > ...

10. Implementing Joined Inheritance in JPA

I'm not sure of the problem you are trying to solve, but there must be other acceptable ways (I hope). If one user using/modifying and existing parent object while another user wishes to turn it into a child object, how would you expect the object identity to be maintained? Parent entities cannot morph into child entity objects in java, so it ...

11. Another JPA problem with deleting a @ManyToMany relationship

I have code (probably seen here before) that has a ConfigurationSet and a ConfigurationBundle bidirectional @ManyToMany relationship. I am not using the cascade delete, but rather am removing the relationships manually and then deciding if I can remove an orphaned entity. Basically when I remove a ConfigurationSet, I disconnect the relationship with the ConfigurationBundles and then I check so see if ...

13. JPA map result query

I'm developing an application using netbeans and visual java Server faces. I did the job very well when tables have only a simple primary key but when it is a compose primary key I don't know how work with that. My database have 3 tables, master products(Articulos), master types(Tipos) and a listprices(listaprecios) I can only see data by this way

14. Accessing ids instead of objects in JPA @ManyToMany relationships

Hi, I'm in the process of converting an application from making direct SQL calls to using JPA. I have two tables, "games" and "players" that now have entity beans and a many-to-many relationship between them. In the database, there is a separate table "game_players" (containing the columns "game_id" and "player_id") that maintains the relationship, and is referenced by the @ManyToMany annotation. ...

15. Override module in glassfish/modules - Hibernate Validation

Hi guys I have encountered a bug in the Hibernate Validation version that is bundled with Glassfish 3. I am trying to deploy my application with a newer version (built from source), but Glassfish won't pick it up. I also tried putting the hibernate-validator.jar in glassfish/lib and domain1/lib, but no difference. It looks like the bundled bean-validator.jar in glassfish/modules is always ...

16. JPA 2.0 Persistent Map Problem

The language field of the map value is to be used as the map key. I absolutely want to avoid duplicating this in a redundant database table column. This is precisely what @MapKey is intended for, if I understand JSR 317 correctly, though there is a bit of vagueness whether or not the map value is allowed to be an embeddable ...