jpa

JPA and derby null pointer exception

I am trying to do a simple persistence with jpa 2.0 and derby but I keep getting a NullPointerException. Exception and entity class - http://pastebin.com/QqXhRdcN The code where I am trying to persist EntityManager em = emf.createEntityManager(); Course c = new Course("cse", 214, "fall", 2010); em.getTransaction().begin(); ...

problem with select statement in many to one relational in EJB3 and JSF

Hi All i wonder how to select between many to one relational i have two table Sub_category and Items sub category is own of relational, it contain list of Items Two class follow: @Entity @Table(name = "item") @NamedQueries({ @NamedQuery(name = "Items.findAll", query = "SELECT i FROM Items i"), @NamedQuery(name = "Items.findBy...

spring-mvc + jpa: data binding

I have simple application which manages football teams and matches. I am using JPA, in the form editMatch.jsp i have property team_1, team_2 (instance of class Team) for choosing the team from the list. The problem is when editing match, the team_1 and team_2 dont select in the list, and after submitting the error message is: Property t...

Problem with auto-generated primary_key using jpa on DerbyDB

I have jpa annotated entity class like: @Configurable @Entity @Table(name="PLAYERS") public class Player { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="ID") private Integer id; @Column(name="NAME") private String name; @PersistenceContext public transient EntityManager entity...

Hibernate v3.6 : Issue with the EntityManager method "refresh"

Hello, The following code throws an exception when invoking "em.refresh(p)": 1: EntityManager em = emf.createEntityManager(); 2: em.getTransaction().begin(); 3: 4: Product p = new Product("J&D", 35.0,"Whisky"); 5: em.persist(p); 6: 7: em.refresh(p); 8: em.getTransaction().commit(); 9: em.close(); When debugging the code, we see that ...

how to set limitation in EntityManager (JPA) L1 or L2 cache size

hi How to set L1 or L2 cache size-limitation. I concern of increasing the cache-size. One way is defining timeout for cache but i want to know is it possible to make a constraint for cache size or not? RGDS Navid ...

Why is JPA choosing String for JoinColumn regardless of key types?

Using the EclipseLink JPA2 implementation (not sure if it's the same with the Hibernate implementation) I have a simple structure where an Organization entity has contracts. Here's the sql I exported from postgres to create the Organization CREATE TABLE organization ( key bigint NOT NULL, version integer ); If I specify the...

EJB3, JPA error with More than one result was returned from Query.getSingleResult()

Hello All! i have new problem with JPA in EJB3 my stacktrace are: Caused by: javax.persistence.NonUniqueResultException: More than one result was returned from Query.getSingleResult() at org.eclipse.persistence.internal.jpa.EJBQueryImpl.throwNonUniqueResultException(EJBQueryImpl.java:1207) at org.eclipse.persistence.int...

JPA ORM Design Patterns

dear all, I need new design patterns in JPA/ORM instead of POJO/JDBC/DAO patterns. Is there any recommended link? RGDS ...

JPA/HIBERNATE - Are objects instances cached indexed just by id ?

Probably it is a basic question, but could not found the answer anywhere in the web. I am trying to use a second level cache (using ehcache) and just checked that some objects were being retrieved from database every time I tried to load them, the only difference was that I was not getting them by id but by a property that carries a SE...

JPA Query - how to get a specific result set?

In an app based on JPA2/Hibernate/Oracle+Spring+Wicket, I use the following model: public class Item { private String name; private Set<Application> apps; private ... } public class Application { private String applicant; private Item item; private Status status; private ... } The mapping between Item and Application is that e...

JPA EclipseLink ManyToMany with Data

Hi, I'm currently trying to implement a ManyToMany Relationship with Data in the JoinTable. I'm following this approach with the Eclipselink JPA Framework. But I'm getting the following exception: org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210) ... 23 more ...

problem with JPA entity

I am using JPA (OpenJPA). I have following entries in my persistence.xml: <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/> I also have Serviceoffering class listed in perisitence.xml. I am getting following exception when I try to run my jpa related code. What can be the problem? No metadata was found for type "c...

How to use java.sql.Timestamp as real java.util.Date with JPA

I have a problem about the management of dates with milliseconds. I understand the need to use the TIMESTAMP to store milliseconds: @Temporal(TIMESTAMP) @Column(name="DATE_COLUMN", nullable = false) @Override public java.util.Date getDate() { return this.date; } But if I can't compare this date to another instance of java.util.Date, u...

JPA/Criteria API - Like & equal problem

I'm trying to use Criteria API in my new project: public List<Employee> findEmps(String name) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Employee> c = cb.createQuery(Employee.class); Root<Employee> emp = c.from(Employee.class); c.select(emp); c.distinct(emp); List<Predicate> criteria = new Arra...

Cannot initialize EntityManager in Netbeans via Junit

I have a bunch of service (ejb 3) classes that i want to unit test. In order to do so, i have added to their implementing classes an overloaded constructor which takes an EntityManager as an argument. The idea is that during my units tests i will create a both an EntityManager instance from a persistence unit specific for my unit tests, ...

Special characters behaviour in Restful web services + Eclipselink + Java

Hello, I have written few Restful web services using Eclipselink for object relation mapping. Now i am calling these services from client side through GET method. Here while passing some special characters as a part of data, i am facing following problems -- 1) + character is storing as space character in database(MySql). 2) How to pas...

Using @GeneratedValue(strategy=GenerationType.TABLE), the sequence_next_hi_value is an int(11) but my table have a id column bigint(20)

Hello, I am using @Id with @GeneratedValue(strategy=GenerationType.TABLE), just checked that hibernate have created a table hibernate_sequences, but the column type for the sequence_next_hi_value is an int(11). I have some entities (I mean tables) that have an id field of type bigint(20), will that works ? and when my table reach the nu...

Need to put @Index even when I marked with @Column(unique=true) ?

Hello, Need to put @Index even when I marked with @Column(unique=true) ? I have a property that will be used frequently to retrieve the entity and wanted to make it an index column on the database. So this property is already marked with @Column(unique=true), do I need to put @Index? thanks ...

Do you think it is necessary to mark id fields with insertable = false and updatable = false ?

Do you think it is necessary to mark id fields with insertable = false and updatable = false ? I haven't seem much people doing this before, but today I checked one code that used these properties setted to false for an id field. Regards ...