jpa-2.0

Is it illegitimate to name an JPA entity “Group”?

会有一股神秘感。 提交于 2020-01-13 09:14:06
问题 I'm developing a JEE6-application, using JPA 2.0 and Hibernate 3.5.2-Final as the Provider (and MySQL 5.1.41). My Application Server is Glassfish V3.0.1. I already have a working CRUD-app with some entities and relationships. Now i added an (really simple) entity with the name "Group". The entity class looks like this: package model //Imports... @Entity public class Group { @Id @GeneratedValue private Long id; @NotNull private String name; //Getters and Setters } Of course I also added it to

how to convert datetime to timestamp in java

半城伤御伤魂 提交于 2020-01-11 10:45:22
问题 forum member I am having one problem with date time in java. Actually I am receiving the startdate in format 2012-02-27T01:10:10 and I want to insert the received date to my database having datetime datatype. Actually I tried to convert the startdate received to datetime by below code String sDate = jsonObject.get("StartDate").toString(); String eDate = jsonObject.get("EndDate").toString(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date startD = sdf.format(sDate); Date endD =

JPA 2.0 (logging and tracing through) with Glassfish 3.0.1 and NetBeans 6.9.1:

我的未来我决定 提交于 2020-01-11 04:46:09
问题 I am using JPA 2.0 ( EclipseLink provider) with Glassfish v3.0.1 and NetBeans 6.9.1 and am NOT able to see the queries and other logging information from JPA 2.0. Essentially I want to be able to see all the SQL statements which are being generated by JPA and other related debugging information... Has anyone successfully been able to configure the logging to provide such feedback? I've tried several things to no avail... Any help would be greatly appreciated. Thanks much. 回答1: What eventually

Weblogic 10.3.3 trying to load org.eclipse.persistence.jpa.PersistenceProvider instead of configured Hibernate Provider

允我心安 提交于 2020-01-10 20:06:34
问题 Good Day all , I am having this problem since many days now , I was able to successfully deploy JPA2.0 appliaction on weblogic 10.3.3 , the application can run select queries using JPA. But when I try to run a create or update information on the same table I get below exception [code] java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider [/code] This is very strange because in my persistence.xml I have

Weblogic 10.3.3 trying to load org.eclipse.persistence.jpa.PersistenceProvider instead of configured Hibernate Provider

[亡魂溺海] 提交于 2020-01-10 20:06:28
问题 Good Day all , I am having this problem since many days now , I was able to successfully deploy JPA2.0 appliaction on weblogic 10.3.3 , the application can run select queries using JPA. But when I try to run a create or update information on the same table I get below exception [code] java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider [/code] This is very strange because in my persistence.xml I have

Abstracting named queries in an abstract JPA DAO

喜你入骨 提交于 2020-01-09 18:34:33
问题 I have an abstract DAO class which uses parameterized types E (Entity) and K (Primary Key). In every entity I have a @NamedQuery . I want to dynamically invoke this named query without knowing its exact name and parameter name. As an example, imagine the following entity City @Entity(name="CITY") @NamedQuery( name="findCityByname", query="FROM CITY c WHERE name = :CityName" ) public class City { // ... } and this CityDao public class CityDao extends AbstractDao<City, Long> { public CityDao()

Abstracting named queries in an abstract JPA DAO

烈酒焚心 提交于 2020-01-09 18:34:10
问题 I have an abstract DAO class which uses parameterized types E (Entity) and K (Primary Key). In every entity I have a @NamedQuery . I want to dynamically invoke this named query without knowing its exact name and parameter name. As an example, imagine the following entity City @Entity(name="CITY") @NamedQuery( name="findCityByname", query="FROM CITY c WHERE name = :CityName" ) public class City { // ... } and this CityDao public class CityDao extends AbstractDao<City, Long> { public CityDao()

How can I make a JPA application access different databases?

拟墨画扇 提交于 2020-01-09 05:33:10
问题 I'm writing a Java SE (desktop) application that has to access different databases all of which will have the same data model (same schema, tables, etc.). I want to reuse the JPA Entities that I already use in a Java EE application that front each database. To reuse the existing entity.jar file I'll have to repackage it with a different persistence.xml that has a resource_local data source. That's an build time inconvenience but not a big problem. The problem is that my desktop application

JPA query timeout

醉酒当歌 提交于 2020-01-07 05:10:57
问题 I am using Open JPA 2.0 - IBM implementation on WebSphere V8. I need to set query timeout at individual query level. How this can be achieved? Using below hint will set timeout for all queries, but I need to control this for specific queries javax.persistence.query.timeout 回答1: Errm, perhaps ... query.setHint("javax.persistence.query.timeout", timeout); 来源: https://stackoverflow.com/questions/13011829/jpa-query-timeout

In JPA which type of parameter is better to use “positional/named”?

混江龙づ霸主 提交于 2020-01-07 02:56:12
问题 With Hibernate as provider. In terms of performance (or others), which type of parameter is better to use? and why? Positional TypedQuery<Client> query = em.createQuery ("FROM Client c WHERE c.clientId = ?1",Client.class); query.setParameter(1, clientId); or Named TypedQuery<Client> query = em.createQuery ("FROM Client c WHERE c.clientId = :clientId",Client.class); query.setParameter("clientId", clientId); 回答1: You should not be really considering performance in this case, named parameters