jpa

Can I use JPA/EJB3 on a table that was created at runtime?

This is weird and probably not possible but I'll ask anyway. I'm making this app that reads in a meta file and creates some tables then populates them with data. I was wondering if I could somehow use JPA to populate those tables. Obviously, there's no way I could have an entity with annotations on it since the table didn't exist at c...

Hibernate Transient Extends problem

@MappedSuperclass public abstract class BaseAbstract implements Serializable{ private static final long serialVersionUID = 1L; protected String test = //some random value; public String getTest() { return test; } public void setTest(String test){ this.test = test; } } @Entity public class Artist extends BaseAbstract { p...

JPA query for getting the whole tree

Hello, I have a class which models all categories and they can be ordered hierarchically. @Entity @Table(name="categories") public class Category { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sequence") @SequenceGenerator(name="sequence", sequenceName="categories_pk_seq", allocationSize=1) @Column(n...

Best practice when removing entity regarding mappedBy collections?

I'm still kind of undecided which is the best practice to handle em.remove(entity) with this entity being in several collections mapped using mappedBy in JPA. Consider an entity like a Property that references three other entities: a Descriptor, a BusinessObject and a Level entity. The mapping is defined using @ManyToOne in the Property...

Setting column length of a Long value with JPA annotations

Hi, I'm performing a little database optimisation at the moment and would like to set the column lengths in my table through JPA. So far I have no problem setting the String (varchar) lengths using JPA as follows: @Column(unique=true, nullable=false, length=99) public String getEmail() { return email; } However, when I want to d...

Creating queries using Criteria API (JPA 2.0)

Hello there ! I'm trying to create a query with the Criteria API from JPA 2.0, but I can't make it work. The problem is with the "between" conditional method. I read some documentation to know how I have to do it, but since I'm discovering JPA, I don't understand why it does not work. First, I can't see "creationDate" which should app...

How to reserve a set of primary key identifiers for preloading bootstrap data

We would like to reserve a set of primary key identifiers for all tables (e.g. 1-1000) so that we can bootstrap the system with pre-loaded system data. All our JPA entity classes have the following definition for the primary key. @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "id", unique = true, nullable = false, insertable =...

PERSISTENCE LOB WITH JPA

Hi, Folks. I have this problem using JBOSS, EJB3 and MSSQL Express . i'm trying to persist an entity with an Blob attribute which was converted into a byte[], apparently it create the entity perfectly, no error was logged at jboss's console. but when i check into database the column is null. i already checked the Object to byte[] method ...

Eager/Lazy loaded member always empty with JPA one-to-many relationship

I have two entities, a User and Role with a one-to-many relationship from user to role. Here's what the tables look like: mysql> select * from User; +----+-------+----------+ | id | name | password | +----+-------+----------+ | 1 | admin | admin | +----+-------+----------+ 1 row in set (0.00 sec) mysql> select * from Role; +----+...

Ternary (and n-ary) relationships in Hibernate

Q 1) How can we model a ternary relationship using Hibernate? For example, how can we model the ternary relationship presented here using Hibernate (or JPA)? NOTE: I know that JPA 2 has added some constructs for building ternary relationships using maps. However, this question assumes JPA 1 or Hibernate 3.3.x and I don't like to use map...

Brainstorming: Weird JPA problem, possibly classpath or jar versioning problem???

I'm seeing a weird error message and am looking for some ideas as to what the problem could be. I'm sort of new to using the JPA. I have an application where I'm using Spring's Entity Manager Factory (LocalContainerEntityManagerFactoryBean), EclipseLink as my ORM provider, connected to a MySQL DB and built with Maven. I'm not sure i...

Foreign Key constraint violation when persisting a many-to-one class

I'm getting an error when trying to persist a many to one entity: Internal Exception: org.postgresql.util.PSQLException: ERROR: insert or update on table "concept" violates foreign key constraint "concept_concept_class_fk" Detail: Key (concept_class_id)=(Concept) is not present in table "concept_class". Error Code: 0 Call: IN...

Are there any modeling tools that can visually generate jpa or sql queries?

Does anyone know of a tool like PowerArchitect or SquirrelSQL or maybe eclipse plugin that lets you also generate jpa/sql queries? Imagine you choosing your database, or your entity beans, and the modeling would reverse engineer your database/entity model, so that you could visually just choose the columns you wanted to select, and it w...

Hibernates generates VARBINARY column with JPA @Enumerated annotation

Hibernates is generating a VARBINARY column with JPA @Enumerated annotation. I'm using SQL Server 2005 w/ JTDS driver. The mapping is dirt simple: @Basic @Enumerated(EnumType.ORDINAL) private MyEnum foo; I would have expected Hibernate to generate an integer column? I've also tried EnumType.STRING (expecting a varchar column) with no ...

JPA query many to one association

I want to build the following pseudo query Select a From APDU a where a.group.id= :id group is a field in APDU class of the type APDUGroup.class. I just want to get a list of APDUs based on APDUGroup's id. How do i do that using a standard JPA query? UPDATE Yes, I have tried the above query and tried other variations for hours befo...

JPA : Inheritance - Discriminator value not taken into account in generated SQL

I try to use this mapping : @Entity @Table(name="ecc.\"RATE\"") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType= DiscriminatorType.STRING) public abstract class Rate extends GenericBusinessObject { ... } @Entity @DiscriminatorValue("E") public class EntranceRate extends R...

Decouple a JPA entities jar from persistence.xml in SE environment

Is there a way to reuse a jar with JPA annotated entities in more than one SE applications (as a dependency)? <jar-file> in persistence.xml is not supported in SE environments so is there another way? ...

(JPA/Toplink) Network error IOException: Address already in use: connect

Hello, I have a JPA project which used to work. This month, I have added some data in my database. When I run the usual job (I used to run on preceeding months), I get this error: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal E...

Two collections manyToOne to same primary key

Hi, guys, I'm coding a web page in Hibernate-JPA and Oracle. I need the following: I have two classes: Place and Home. I need two collections of type Place in every Home: I do the following: Home: @ManyToOne @JoinColumn(name="ID_PLACES") private List<Places>places1; @ManyToOne @JoinColumn(name="ID_PLACES") private List<Places>Pl...

can't persist jpa entity in app engine

@Entity public class Blobx { private String name; private BlobKey blobKey; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key id; //getters and setters } @Entity public class Userx { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private...