openjpa

Encrypting Parameters in persistence.xml

We have a batch application using OpenJPA. We are specifying all the DB connection parameters in persistence.xml. Although its a functional setup it looks very insecure to have all the ip,username,password in clear text and a serious concern in production. As it is a standalone batch app we cant use server configurations etc. Is there a...

Nullable Date column merge problem

I am using JPA with openjpa implementation beneath, on a Geronimo application server. I am also using MySQL database. I have a problem with updating object with nullable Date property. When I'm trying to merge entity with Date property set to null, no sql update script is generated (or when other fields are modified, sql update script is...

Beginner question: basic insertion idiom for JPA?

My "HelloJPA" code (below) tries to store an Employee in a datastore. However, any attempt to read the persisted object after committing the (resource local) transaction is rewarded with an "IllegalStateException": Employee employee = ... EntityManagerFactory factory = Persistence.createEntityManagerFactory( "HelloJPA", System.getPr...

Problem with bidirection ManyToOne

I have two entities: Message and GeneratedMemberMessage. There are more fields than I'll show in code here, but these should provide enough for context to my question. I'm trying to do a simple bidirectional OneToMany relationship and from all that I've read, this is how it's to be done. You'll notice that I'm using composite keys. ...

JPA concatenating table names for parent/child @OneToMany

We are trying to use a basic @OneToMany relationship: @Entity @Table(name = "PARENT_MESSAGE") public class ParentMessage { @Id @Column(name = "PARENT_ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer parentId; @OneToMany(mappedBy="parentMsg",fetch=FetchType.LAZY) private List childMessages; public List g...

Is there any advantage for using a library other than Hibernate for JPA?

Hi, I've been using JPA for some time now and been in projects where we've used both Hibernate Annotations and Toplink Essentials. AFAIK the project leader chose Toplink because Netbeans had it integrated and seemed to be the easy thing to do. However when looking for help, most of the literature seemed to assume that you are using Hi...

The type of field isn't supported by declared persistence strategy "OneToMany"

We are new to JPA and trying to setup a very simple one to many relationship where a pojo called Message can have a list of integer group id's defined by a join table called GROUP_ASSOC. Here is the DDL: CREATE TABLE "APP"."MESSAGE" ( "MESSAGE_ID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) )...

Persisting a List of Integers with JPA?

We have a pojo that needs to have a list of integers. As an example, I've created a Message pojo and would like to associate a list of groupIds (these ids need to be queried and displayed in the UI). So ideally, we would like to be able to do something like this: Message msg = em.find(Message.class, 101); List<Integer> groupIds = msg.ge...

Help with JPQL query

I have to query a Message that is in a provided list of Groups and has not been Deactivated by the current user. Here is some pseudo code to illustrate the properties and entities: class Message { private int messageId; private String messageText; } class Group { private String groupId; private int messageId; } class Deactiva...

How to do a timestamp comparison with JPA query?

We need to make sure only results within the last 30 days are returned for a JPQL query. An example follows: Date now = new Date(); Timestamp thirtyDaysAgo = new Timestamp(now.getTime() - 86400000*30); Query query = em.createQuery( "SELECT msg FROM Message msg "+ "WHERE msg.targetTime < CURRENT_TIMESTAMP AND msg.targetTime > {ts, '...

What does setting SubclassFetchMode (Kodo OpenJPA) actually do?

What does setting SubClassFetchMode e.g. to EAGER_PARALLEL actually do? Why would one want a subclass to have a different FetchMode? The implementation spec for KODO and OpenJPA is notoriously bad and I can't figure it out. ...

Class not found exception (org.apache.openjpa.enhance.PersistenceCapable) thrown in a client of WLS 10

I am developing an aplication using WLS 10 When i try to conect (lookup) to an EJB from a specific jar of my ear aplication, an exception of type "ClassNotFoundException" of the class "org.apache.openjpa.enhance.PersistenceCapable" is thrown in the client has anybody found a reason for this workaround? Thanks in advance ...

multiple search fields

What will be the best approach if I have search fields for 20 or more and any combination should be valid. Is there any special way to do it in openJPA or native SQL is better. Any idea would be helpful.Thanks. ...

KODO: how set up fetch plan for bidirectional relationships?

Running KODO 4.2 and having an issue inefficient queries being generated by KODO. This happens when fetching an object that contains a collection where that collection has a bidrectional relationship back to the first object. Class Classroom { List<Student> _students; } Class Student { Classroom _classroom; } If we create...

JPA ManyToMany referencing issue

I have three tables. AvailableOptions and PlanTypeRef with a ManyToMany association table called AvailOptionPlanTypeAssoc. The trimmed down schemas look like this CREATE TABLE [dbo].[AvailableOptions]( [SourceApplication] [char](8) NOT NULL, [OptionId] [int] IDENTITY(1,1) NOT NULL, ... ) CREATE TABLE [dbo].[AvailOptionPlanTypeA...

How to find out efficiently the auto-generated id for a new object when using JPA?

Hello, I have an attribute which is annotated with @Id. The ID is going to be generated automatically when persisting the object. That means that the ID-value is not defined before I persist the object. After persisting it, it has an ID (in the database), but unfortunately the field still remains null as long as I don't reload it from t...

OpenJPA - not flushing before queries

hi all, how can i set openjpa to flush before query. When i change some values in database i want to propagate these changes into application. I tried this settings in persistence.xml: <property name="openjpa.FlushBeforeQueries" value="true" /> <property name="openjpa.IgnoreChanges" value="false"/> false/true - same behavior to my cas...

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...

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 ...

sql query with space in the value

How do I write where clause where the value has spaces: Actually I am using openJPA and I have to set parameter. The value i will be setting has a space, eg: String somevalue="firstname lastname"; query.setparameter(somevalue); I did this but doesnot work. Any suggestion will be appreciated. Thanks. ...