eclipselink

JPA EclipseLink oneToMany Derived Ids Fail

允我心安 提交于 2020-01-07 07:40:06
问题 Hello I'm trying to make an example of persistence of a OneToMany relationship in which I get the following error: Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [entitys.OrderItemPK] and those of the entity bean class [class entitys.OrderItem] must correspond and their types must be the same. Also, ensure that you have specified ID elements for the corresponding attributes in XML and/or an @Id on

EclipseLink (JPA 2.1) Query not returning results where it clearly should

别说谁变了你拦得住时间么 提交于 2020-01-07 03:48:11
问题 I am trying to retrieve the next page of results from the database using the code below. public Collection<Product> getCategoryProducts(Category selectedCategory, String start) { Query query = em.createQuery("SELECT p FROM Product p WHERE p.categoryId = :categoryId") .setParameter("categoryId", selectedCategory) .setMaxResults(20); if (null != start) { query.setFirstResult(Integer.parseInt(start)); } return query.getResultList(); } My Product table has about 1000 rows where each product

GlassFish 4.1.1 Spring 4.0.9, EclipseLink, PostgreSQL - transaction marked for rollback with no information

旧城冷巷雨未停 提交于 2020-01-06 20:55:16
问题 I want to set up an application running on GlassFish 4.1.1 with EclipseLink and Spring. My database is PostgreSQL. Below is my configuration. When I try to invoke /facebookDebug method I get "javax.transaction.RollbackException: Transaction marked for rollback" which is not very descriptive. Please look at my configuration. Is there everything ok? I can add a log from the server start, maybe you will find something there. persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence

GlassFish 4.1.1 Spring 4.0.9, EclipseLink, PostgreSQL - transaction marked for rollback with no information

China☆狼群 提交于 2020-01-06 20:54:14
问题 I want to set up an application running on GlassFish 4.1.1 with EclipseLink and Spring. My database is PostgreSQL. Below is my configuration. When I try to invoke /facebookDebug method I get "javax.transaction.RollbackException: Transaction marked for rollback" which is not very descriptive. Please look at my configuration. Is there everything ok? I can add a log from the server start, maybe you will find something there. persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence

Entity Object Not Getting Persisted: New object was found through a relationship that was not marked

爱⌒轻易说出口 提交于 2020-01-06 19:56:00
问题 I am trying to persist the following entity: public class CommentEntity { @Id @ManyToOne(optional=false,cascade=CascadeType.REFRESH, targetEntity=UserEntity.class) @JoinColumn(name="USERID",referencedColumnName="USERID") private UserEntity userEntity; @ManyToOne(optional=false,cascade=CascadeType.REFRESH, targetEntity=PostEntity.class) @JoinColumn(name="POSTID",referencedColumnName="POSTID") private PostEntity postEntity; } But the error comes out: During synchronization a new object was

Why SingularAttribute is not Serializable?

戏子无情 提交于 2020-01-06 19:42:52
问题 I want to pass a metamodel attribute of a JPA entity as a parameter to the remote interface of a session bean. As you know, type of this object is javax.persistence.metamodel.SingularAttribute . I was using Hibernate previously and there was no problem, but now with EclipseLink, metamodel attributes is not Serializable . It seems that EclipseLink populate attributes with not serializable objects. Why? I am using Glassfish 3.1.2.2 and my project dependencies are as below: <dependency> <groupId

Eclipselink with MongoDB - cast exception [duplicate]

扶醉桌前 提交于 2020-01-06 06:41:42
问题 This question already has answers here : Eclipselink with MongoDB java.lang.ClassCastException (3 answers) Closed 4 years ago . I'm getting stuck in configuring JPA for Mongodb. Here is my stack exception : [EL Config]: connection: 2014-03-31 10:48:24.171--ServerSession(1883377923)--Connection(1001688235)--Thread(Thread[main,5,smarttrade])--disconnect [EL Severe]: ejb: 2014-03-31 10:48:24.181--ServerSession(1883377923)--Thread(Thread[main,5,smarttrade])--java.lang.ClassCastException: org

Create custom JPA query function

妖精的绣舞 提交于 2020-01-06 05:46:04
问题 I'm using EclipseLink. Is is possible to use custom query function like: Select u from User u where my_function(u.name) = my_function(:param) I would like to retrive entities based on custom created slug names rather than id (and remove any id's from url) 回答1: If you implement it as function in database then it is possible, otherwise not (because it translates to SQL in the end anyway calls to method implemented with Java are not possible). Keyword func is used to call database function:

TypedQuery<x> returns vector of Object[] instead of list of x-type object

此生再无相见时 提交于 2020-01-06 03:43:31
问题 I have a method: public List<Timetable> getTimetableTableForRegion(String id) { List<Timetable> timetables; TypedQuery<Timetable> query = em_read.createQuery("SELECT ..stuff.. where R.id = :id", Timetable.class).setParameter("id", Long.parseLong(id)); timetables = query.getResultList(); return timetables; } which returns this: so, what am I missing in order to return a list of Timetable 's? 回答1: ok, so, ..stuff.. part of my JPQL contained an inner join to other table. Even through in SELECT

EclipseLink generated SQL doesn't include pagination

孤街浪徒 提交于 2020-01-06 03:07:49
问题 (My environment: Windows 7 x64 and Server 2008, EclipseLink 2.5.2, I've tried the following with JTDS and the MS JDBC driver, and with MS SQL Server Express 2008 and 2012.) I'm doing a paginated query in a table with anywhere from 5-50 million rows, with about 5 million rows matching the filter criteria. The following is the paginated query I'm using to display this data in the UI 25 rows at a time. The pagination is working properly - the list contains just 25 rows for each page. However,