jpa

Mapping BPCHAR in JPA

One of the properties in my entity is mapped to bpchar (BLANK PADDED CHAR) string. @NotNull @Column(name = "property", columnDefinition = "bpchar") private String property; When I save entity and load back, then my property is padded with spaces, that is correct from the database point of view. But I want to work in code with trimmed...

can OptimisticLockException occur if app srv Isolation level is set to READ COMMITTED?

I am using Websphere application server 7.0.0.0.9 with ;OpenJPA 1.2.3-SNAPSHOT'. I have Set property of jdbc data source webSphereDefaultIsolationLevel=2 (READ COMMITTED). I have this question because My understanding is the OptimasticLockException occurs if there is race to commit the same row by multiple thread. But I think this sit...

JPA - database gets updated only when method is @Transactional

I've encountered a problem I don't really understand - unless a method working with the DAO is annotated as @Transactional, the underlying database doesn't get updated. My app runs on JPA/Hibernate, Spring and Wicket. Why is that? DAO: @Repository(value = "userDao") public class UserDaoJpa implements UserDao { @PersistenceContext ...

JPA - using annotations in a model

My application runs on JPA/Hibernate, Spring and Wicket. I'm trying to convert our ORM from XML files to JPA annotations. The annotated model looks like this: @Entity @Table(name = "APP_USER") public class User extends BaseObject { private Long id; private String firstName; private String lastName; private String email; ...

Migrating JUnit JPA tests from Spring 2.5.5 to Spring 3.0.4

Our project has just decided to migrate from Spring 2.5.5 to Spring 3.0.4. In my original code, I had unit tests that looked like the following: public class RequisitionDaoTest extends AbstractJpaTests { public static String FAIL_MSG_UNEXPECTED_ERROR = "FAIL: Unexpected Error"; @PersistenceContext private EntityMa...

CollectionAttribute testing in JPA CriteriaBuilder

Hi, I have a CriteriaBuilder and am trying to create a predicate to restrict results in a CollectionAttribute. I would like to say something like get all entities in this collection where the entity's attribute A equals x. For example, I have lots of People entities. They have a collection of job titles (previous and current) and I'd lik...

Spring-WS and Straight-JPA (EclipseLink) Configuration and Deployment

Hey guys, I've implemented an EJB3/JPA web service without any major problems, and now I've moved on a Spring-WS/JPA web service. Both are being deployed to Glassfish. My understanding of JPA is limited, but by default transactions are container managed? How do you change this? With EJB3 things were straight forward as I could just inj...

JPA+Address Book Demo+Netbeans 6.9.1 problem

I'm trying to include persistence to a Vaadin project so my first step was to try the JPA+Address Book Demo using Netbeans. When I try to run the demo I get a "StandardWrapperValve[VaadinApplication]: PWC1406: Servlet.service() for servlet VaadinApplication threw exception". I tried by adding gwt-user.jar but it didn't work. My knowledg...

override persistence.xml in ejb3

I am facing issue to override persistence.xml in jboss and with Hibernate JPA provider, I spent couple of nights but I couldn't solve it. I am using jboss + hibernate + mysql + ejb3. My requirement is I will provide the connection URL and the persistence unit will connect to the DB but it will be dynamically. so my code below. If anyone ...

JPA/HSQLDB is still eating all my memory

Hi guys, I'm working on a program that parses data from a file and stores it into a HSQLDB database. As the parser encounters data it creates entities which are mapped to the database using JPA/Hibernate. My problem is that while the parsing is being performed the application uses more and more memory. I have successfully used cached ta...

Autocommit OpenJPA writes

I'm using OpenJPA and want to configure it to use Autocommit on every write/insert operation. At the moment I have to do this: MyEntity e = new MyEntity(); em.getTransaction().begin(); em.persist(e); em.getTransaction().commit(); What I want to be able to do is this: MyEntity e = new MyEntity(); ...

How to find and store the number of times a user was part of a search criteria

LinkedIn provides a mechanism to say that the user was part of a search criteria "n" number of times in the last "x" days. How do you go about capturing and storing the information. Are you supposed to iterate the search results and put an appropriate counter whenever they get searched or is there a non-intrusive mechanism by which this ...

What's the "low risk" choice between JDO or JPA?

Do not close this as a duplicate of other questions because I'm not asking the same thing. They're also about a year old. That said, see these links: http://db.apache.org/jdo/jdo_v_jpa.html http://www.datanucleus.org/products/accessplatform/jdo_jpa_faq.html http://www.datanucleus.org/products/accessplatform/persistence_api.html It se...

How to do bulk delete in JPA when using Element Collections?

I am having trouble working out how to do a bulk delete of a Person object using JPA, when the Person objects contain data stored using an @ElementCollection. Any ideas on how to do this would be much appreciated. @Entity @Table(name="at_person") public class Person implements Comparable<Person> { @Id @GeneratedValue(strategy =...

Difference between JTA, JPA and Plain JDBC in hibernate

Hi, Can anyone tell me what is the difference between JTA, JPA, and Plain JDBC in terms of hibernate? I have been asked continuously this question and I fumble while giving the answer. Best Regards, Aashutosh ...

problem with using JPA

I am getting following exception while i try to execute simple jpa code. What may be the casue? 5453 DevPQRWDPBSSPersist WARN [P=351601:O=0:CT] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "[class com.XYZ.PQ...

How to mix inheritance strategies with JPA annotations and Hibernate?

According to the Hibernate Reference Documentation it should be possible to mix different inheritance mapping strategies when using Hibernate's XML-Metadata: http://docs.jboss.org/hibernate/stable/core/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass However, the corresponding section of the Hibernate...

hibernate auto create in-memory hsqldb causes Sequence not found

I'm using hibernate as my jpa provider and want it to create a in-memory hsqldb on startup using: hibernate.hbm2ddl.auto=create But for some reason I get exceptions like below in my logs. Things seems to work otherwise. Is it a hibernate or hsqldb problem? I'm limited to using jpa 1 so I'm using hsqldb 1.8.0.10 and hibernate 3.3.0.SP...

Creating entities from a postgresql 9.0.1 database with Netbeans 6.9.1

Basically it doesn't work ... I can install the jdbc driver for pg 90 in netbeans and browse the database, issue sql commands etc. But creating entity beans from the tables via the same connection does not work, Netbeans can't find any tables in the database. Do I have to downgrade to pg 84, or are there some tricks to make it work? ...

JPA/Hibernate support for migration?

Aloha, I'm currently working on a desktop application using JPA/Hibernate to persist data in a H2 database. I'm curious what my options are if I need to make changes to the database schema in the future for some reason. Maybe I'll have to introduce new entities, remove them or just change the types of properties in an entity. Is there...