jpa

JPA - Can I create an Entity class, using an @DiscriminatorValue, that doesn't have its own table?

Hi - this is potentially a bit complex, so I'll do my best to describe my situation - it's also my first post here, so please forgive formatting mistakes, etc! I'm using JPA with joined inheritance and a database structure that looks like: ACTION --------- ACTION_ID ACTION_MAPPING_ID ACTION_TYPE DELIVERY_CHANNEL_ACTION ---------------...

JPA/Hibernate and messed up named parameters

My simple query looks like this on JPQL: SELECT COUNT(r) FROM org.domain.Resource r WHERE r._parent = :parent AND r._metadata[:metadataKey] is not null But Hibernate SQL output looks like this (both for H2 and MySQL): select count(resource0_.id) as col_0_0_ from resources resource0_, resou...

How do I limit JPQ output?

I need to limit number of entities returned by a query to some certain value inside a JPA query (through JPQL). Particularly: select m from Manual m //constraint e.g. in sql (mysql syntax) I would do it like: select * from Manual limit 1 The only solution that comes up is simply to get all entities and then choose first one, which ...

Provider error. Provider: org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider

I am using Google App Engine Eclipse Plugin and in a project I try to create entity manager using jpa. but eclipse gives me the error "Provider error. Provider:org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider" How can I solve this issue? ...

What causes this org.hibernate.MappingException?

I'm trying to configure an ejb3 sample application, it's entities where mapped to postgres now I want the app run on Jboss4.3 and Informix using JPA. If the DDL creation <property name="hibernate.hbm2ddl.auto" value="create"/> is active this error appears > WARN [ServiceController] Problem > starting service > persistence.units:ear=we...

Which are the differences/similarities between hibernate and other frameworks or specifications?

I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5? I'm not clear if Hibernate implements Java EE 5 persistence implementation or if it is a totally different approach to data representation over back-end systems. I'm confused about Hibernate and its relation with the concepts about java p...

JPQL / SQL: How to select * from a table with group by on a single column?

I would like to select every column of a table, but want to have distinct values on a single attribute of my rows (City in the example). I don't want extra columns like counts or anything, just a limited number of results, and it seems like it is not possible to directly LIMIT results in a JPQL query. Original table: ID | Name |...

Hibernate @OneToOne @NotNull

Is it valid to declare @OneToOne and @NotNull on both sides of a relationship, such as: class ChangeEntry { @OneToOne(cascade=CascadeType.ALL) @NotNull ChangeEntryDetails changeEntryDetails; public void addDetails(ChangeEntryDetails details) { this.changeEntryDetails = details; details.setChangeEntry(this)...

Exception in inserting data into data using JPA in netbeans

SEVERE: Local Exception Stack: Exception [EclipseLink-7092] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="Voter.findAll" referenceClass=Voter jpql="...

JPA @OneToMany and composite PK

Good Morning, I am working on project using JPA. I need to use a @OneToMany mapping on a class that has three primary keys. You can find the errors and the classes after this. If anyone has an idea! Thanks in advance! FF javax.persistence.PersistenceException: No Persistence provider for EntityManager named JTA_pacePersistence: P...

JoinColumn name not used in sql

Hi! I have a problem with mapping many-to-one relationship without exact foreign key constraint set in database. I use OpenJPA implementation with MySql database, but the problem is with generated sql scripts for insert and select statements. I have LegalEntity table which contains RootId column (among others). I also have Address tabl...

Execute sql script after jpa/EclipseLink created tables?

Hello, is there a possibility to execute an sql script, after EclipseLink generated the ddl? In other words, is it possible that the EclipseLink property "eclipselink.ddl-generation" with "drop-and-create-tables" is used and EclipseLink executes another sql-file (to insert some data into some tables just created) after creating the ta...

JPA - Use case - How to make entity

Hello... I have server Entities.... Suppose an Entity named Exam this entity has a long ID... There are serveral types of exams... Exam_Numeric, Exam_Boolean etc..... which use the same ID (shared id) with Exam... depending on the type of the exam... My problem is that i want to make an other type called Exam_Composite This entit...

Hibernate Criteria API - adding a criterion: string should be in collection

I have to following entity object @Entity public class Foobar { ... private List<String> uuids; ... } Now I'd like to make a criteria query which would fetch all Foobar pojos whose uuids list contains the string "abc123", I'm just not sure how to make the appropriate criterion. ...

How to set up default schema name in JPA configuration?

I found that in hibernate config file we could set up parameter hibernate.default_schema: <hibernate-configuration> <session-factory> ... <property name="hibernate.default_schema">myschema</property> ... </session-factory> </hibernate-configuration> Now I'm using JPA and I want to do the same. Otherwise I have...

Replacing ORM schema without dropping the entire data

Hey, I'm using OpenJPA as a JPA provider. Is there a way in which I can recreate the database tables (When an entity changes) without dropping the entire data? When an entity changes, I drop and create every table in the store, and obviously lose the data within. Is there a tool or product to keep the data somehow? Thanks, Udi ...

JPA 2.0 Eclipse Link

I have this code @Column(updatable=false) @Enumerated(EnumType.STRING) private ExamType examType; However, I can still change the value when I update it via merge. Why? ...

How to use an external file for database configuration in EJB environment

I need to have a file for database configuration outside of EAR file of my EJB application. Even if I define a datasource and call it via JNDI, I still have some properties that I want to change, like hibernate.dialect or hibernate.show_sql, for example. I tried using: <property name="hibernate.ejb.cfgfile" value="some-file.xml" /> an...

JPA @TableGenerator shared between multiple entities

Hi Guys, I have a 'dog' Entitiy with an @Id and a @TableGenerator ... @TableGenerator(table = "seq", name = "dog_gen", pkColumnName = "seq_name", valueColumnName="seq_val") @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog_gen") private Long id; ... Is there a way to reuse the same table generator (dog_gen) in othe...

JPA IndirectSet changes not reflected in Spring frontend

EDIT: Solved, but I don't know what was different now. If anyone can explain what happened differently, I'd appreciate it. The way it's working now is by merging only the Parent, not the Child at all, like so: Parent parent = child.getParent(); parent.getChildren().add(child); getJpaTemplate().merge(parent); Now, it seems to be worki...