jpa

What are the alternatives to using an ORDER BY in a Subquery in the JPA Criteria API?

喜你入骨 提交于 2021-02-18 22:01:57
问题 Consider the following two tables: Project ( id, project_name) Status ( id, id_project, status_name) Where Status contains all statuses in which a Project has been. Lets say we want to query all projects for which the latest status has the name "new". The Sql query that I come up with is: SELECT q.id_project FROM status q WHERE q.status_name like 'new' AND q.id IN ( SELECT TOP 1 sq.id from status sq WHERE q.id_project = sq.id_project ORDER BY sq.id DESC ) I'm trying to replicate the above

What are the alternatives to using an ORDER BY in a Subquery in the JPA Criteria API?

末鹿安然 提交于 2021-02-18 22:00:39
问题 Consider the following two tables: Project ( id, project_name) Status ( id, id_project, status_name) Where Status contains all statuses in which a Project has been. Lets say we want to query all projects for which the latest status has the name "new". The Sql query that I come up with is: SELECT q.id_project FROM status q WHERE q.status_name like 'new' AND q.id IN ( SELECT TOP 1 sq.id from status sq WHERE q.id_project = sq.id_project ORDER BY sq.id DESC ) I'm trying to replicate the above

Table 'customerjpa.sequence' doesn't exist JPA

六月ゝ 毕业季﹏ 提交于 2021-02-18 18:46:37
问题 I am facing following problem while inserting data into table using single inheritance in jpa. run: [EL Info]: 2014-04-17 22:40:45.947--ServerSession(863001717)--EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20110202-r8913 [EL Info]: 2014-04-17 22:40:46.387--ServerSession(863001717)--file:/C:/Users/xone/Documents/NetBeansProjects/JPAAditiDAS/build/classes/_TESTJPAPU login successful [EL Warning]: 2014-04-17 22:40:46.469--ClientSession(1037426453)--Exception [EclipseLink-4002]

How to configure persistence.xml provider tag

萝らか妹 提交于 2021-02-18 18:14:41
问题 Hey I'm learning this stuff, I don't really understand all of it and I have a problem, I don't know what to write in provider tag in persistence.xml Here are my persistence.xml and pom.xml files: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com

How to configure persistence.xml provider tag

北城余情 提交于 2021-02-18 18:14:09
问题 Hey I'm learning this stuff, I don't really understand all of it and I have a problem, I don't know what to write in provider tag in persistence.xml Here are my persistence.xml and pom.xml files: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com

How to use date_format when using JPQL/JPA

孤街醉人 提交于 2021-02-18 17:11:05
问题 I am doing Java EE with MySQL as database and implementing JPA on my codes. I have no problem retrieving the data from MySQL Workbench but when I change my syntax to JPQL's it does not work. For e.g. in MySQL - it works SELECT date_format(s.date,'%Y, %m, %d') from Transactions s; in JPQL - it does not SELECT date_format(s.date,'%Y, %m, %d') from TransactionEntity s; How do i modify to suit the JPA query? Note: in JPQL the following works SELECT s.date from TransactionEntity s; 回答1: SQL

Eclipse does not show EclipseLink platform in JPA configuration [closed]

左心房为你撑大大i 提交于 2021-02-18 17:00:20
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Improve this question I'm trying to set up JPA facet. All tutorials online state that I should select EclipseLink platform and not Generic. The thing is in my eclipse only Generic appears. I've installed Eclipse Web tools hoping that it would appear but looks like I need to add

Specfiy columns which should be considered for distinct calculation

孤街醉人 提交于 2021-02-18 12:18:12
问题 I'm using javax.persistence.criteria.CriteriaBuilder and javax.persistence.criteria.CriteriaQuery to select some entities. I now want to select only the entities that are unique which should be specified by a certain column. There is the method javax.persistence.criteria.CriteriaQuery#distinct which only returns unique entities. I would rather need something like CriteriaQuery<T> distinct(String... columnNames) Do you know how I can bake such a distinct in my JPA CriteriaQuery ? It seems to

JPA Native query get a Single Object

佐手、 提交于 2021-02-18 12:17:06
问题 How can i get a single object by using JPA Native query. I did some researches but all give an answer is use "getSingleResult", however it didn't return what i want to get. For example, what should i do if i want to get a count of table in my database and fetch it into a Integer. This code below shows how i get this by using Sessison hibernate: int check = Integer.parseInt((String) sessionF.createSQLQuery("select to_char(count(*)) as count from user_tables where table_name upper('TEST')")

EJB/JPA Transaction Boundaries

情到浓时终转凉″ 提交于 2021-02-18 11:17:10
问题 I was reading EJB Transaction boundary and Transaction boundary Lets concentrate on RequiresNew Attribute . Here is the modified diagram from the link So let say method-B is annotated with RequiredNew attribute . so according to theory when method-A calls method-B a new transaction will be start and the already started transaction will be suspended, and when method-B returns the new transaction will be committed. Now consider that in section S1 we create a jpa entity using entitymanager