Skip to content

Tag: jpa

how to store date AND time with JPA in Oracle?

I’m using WebSphere 7 (Java EE 5) and OpenJPA 1.2.1. I have a JPA object with a “modifiedTimestamp” attribute, something like this: The related field in the Oracle database is of type DATE. I set the date like so … … and it gets stored, but when I read it back the time of day has…

Problems with making a query when using Enum in entity

I have the following in a Question entity: and I am getting this exception: Exception Description: Error compiling the query [Question.countApproved: SELECT COUNT(q) FROM Question q WHERE q.status = ‘APPROVED’], line 1, column 47: invalid enum equal expression, cannot compare enum value of type [m…

Getting old data with JPA

I’m getting old data with JPA, even if I disable the cache. I guess is because the resource is configured to be RESOURCE_LOCAL, but I’m not sure. My code that is getting old info about the user: My entity: Anybody has some idea of what is going on? UPDATE 1 The begin, flush and commit methods were…

JPA: unidirectional many-to-one and cascading delete

Say I have a unidirectional @ManyToOne relationship like the following: If I have a parent P and children C1…Cn referencing back to P, is there a clean and pretty way in JPA to automatically remove the children C1…Cn when P is removed (i.e. entityManager.remove(P))? What I’m looking for is a…