eclipselink

Does EclipseLink support ORDER BY FIELD(field, :values)

放肆的年华 提交于 2019-12-12 02:34:16
问题 MySQL supports queries such as: SELECT id FROM users WHERE id IN(3,4,8,1) ORDER BY FIELD(id, 3,4,8,1); Does EclipseLink support this query (without reverting to a native query)? When I try the following: Select id from User user where user.id in :ids ORDER BY FIELD(user.id, :ids) I receive the error: Syntax error parsing the query ... line 1, column 98: unexpected token [(]. 回答1: ORDER BY FIELD(field, :values) is not supported by JPA (JQL) or EclipseLink. JPA does provide a mechanism to

How to refresh cache after persist?

半腔热情 提交于 2019-12-12 02:29:48
问题 I am using JPA (EclipseLink 2.5) for persistence. My web app contains AJAX page updates. When a post is saved, the posted content shows up without refreshing the browser. The post have tags associated with it using a OneToMany relationship. These tags are supposed to show up after save too. However, because the cache was enabled I was not able to get the tags. Here's my code: @TransactionAttribute(TransactionAttributeType.REQUIRED) public Sqask save(AskTag tags) { try { Sqask ask = saveAsk

JPA: @OneToMany(fetch = FetchType.EAGER), pagination and duplicates

跟風遠走 提交于 2019-12-12 02:13:29
问题 I use eclipselink as a JPA provider. I have an entity Article which has many Authors (this field is marked @OneToMany(fetch = FetchType.EAGER) ). Article and authors are loaded together using only one sql query (JOIN). To work with pagination I use the following code: String queryString="SELECT DISTINCT e FROM Article e LEFT JOIN FETCH e.authors"; Query query = em.createQuery(queryString); query.setHint("eclipselink.join-fetch", "e.authors"); query.setFirstResult(position); query

@TableGenerator not working with EclipseLink JPA 2.0

浪尽此生 提交于 2019-12-12 02:08:23
问题 I am having a weird issue. i am using Table Generation strategy in my JPA application. until recently, I used Toplink persistence provider as the JPA implementation. All worked fine. Just now I added some inheritance features that are not supported by TopLink (Table per Class Inheritance), so I had to move to EclipseLink. All works fine, except for the ID Generation. Here is the code example which I use for all my unique IDs: @Id @TableGenerator(name="INCOME_SEQ", table="SEQUENCE_TABLE",

SQL for NamedQuery in EclipseLink

核能气质少年 提交于 2019-12-12 01:34:47
问题 I want to write following query as NamedQuery in Eclipselink select o from user o where trunc(o.TRSF_DATE) = ?1 and o.contrno in(?2,?3,?4,?5,?6,?7,?8,?9,?10,?11) I am getting following error Internal Exception: NoViableAltException(83!=[661:1: simpleConditionalExpressionRemainder[Object left] returns [Object node] : (n= compariso nExpression[left] | (n1= NOT )? n= conditionWithNotExpression[(n1!=null), left] | IS (n2= NOT )? n= isExpression[(n2!=null), left] );]) at org.eclipse.persistence

eclipselink jpa criteria reference unmapped column

梦想与她 提交于 2019-12-12 01:26:44
问题 when writing jpql queries I can reference not mapped columns with COLUMN() (I know it is eclipselink specific). Is there any way I can reference unmapped column when building criteria using javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.Predicate, etc? The problem I am facing: I have postgresql table with full text search column. I do not want it to be mapped to entity objects but I qould like to use is in queries (and I need also queries using CriteriaBuilder). Edit:

static weaving eclipselink jpa with spring and tomcat

不打扰是莪最后的温柔 提交于 2019-12-12 01:26:07
问题 I am trying to achieve static weaving with Eclipselink+Spring+JPA using maven. I have configured my spring project with Java Configuration, no context.xml. I tried following things: In persistence.xml: Added following weaving specification. <property name="eclipselink.weaving" value="static" /> In DBConfig.java, I have configured beans as follow : @Bean() public DataSource getDataSource() { BoneCPDataSource ds = new BoneCPDataSource(); log.debug("Driver Name : " + driverClassName); try {

Don't changed data on jsp after update data in postgresql

孤街醉人 提交于 2019-12-12 00:00:36
问题 I have class to get data from db and servlet for send this data to jsp. If i insert or delete row in the table (using pgAdmin), data on jsp is updated (with new data), but if i update existing date in table, it's not updated on the jsp (only after restart glassfish). Class using for ORM: package db_classes; @Entity public class heading { private Integer id; private String name; private Long themeCount; private Collection<topic> topicsById; @Id @Column(name = "id") public Integer getId() {

Eclipselink Inheritance policy causing malformed query

孤街浪徒 提交于 2019-12-11 23:45:00
问题 There are three entities namely Employee, Person and Address. There is a parent-child relationship between Person and Employee (Employee IS-A Person). There is a 1:1 relationship from Person to Address. (A Person is assumed to have one permanent address). The key properties of Employee class are: 1. employeeId(pk) 2. personId(fk) The key properties of Person class are: 1. pId(pk) 2. pCode The key properties of Address class are: 1. addressId(pk) 2. employeeId(fk) The following are the

eclipselink SQLServerException inserting into a join table with additional column

限于喜欢 提交于 2019-12-11 23:05:40
问题 I have a many-to-many relationship which looks like this: The primary key is combination of three columns and I'm using eclipselink. I created these classes to be able to insert in the join-table : @Entity @Table(name = "definition_property") @NamedQueries({ @NamedQuery(name = "DefinitionProperty.findAll", query = "SELECT d FROM DefinitionProperty d")}) public class DefinitionProperty extends AbstractEntity{ private static final long serialVersionUID = 1L; @EmbeddedId protected