Questions tagged [jpa]

The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects/classes and a relational database. It is part of the EJB 3.0 specification and is the industry standard approach for Object to Relational Mapping (ORM).

0
votes
0answers
10 views

Is it possible to group duplicate foreign key values when storing with JPA?

In my Spring Boot application two entities have a Many-To-Many relationship with each other, Parent and Child. I have an async processor that grabs some data to build and store Parents. As I'm ...
0
votes
0answers
15 views

One entity class for repository that calls stored procedure with multiple joins from different tables

I have a repository that calls a stored procedure in my database. The stored procedure join on three different tables and returns a list where each row contains 5 variables. These variables come from ...
0
votes
0answers
22 views

Persisting a temporal collection with JPA

I need to persist with JPA a collection which changes temporally. Suppose I have a Customer making multiple Orders at a time, I'd need operations like: Customer c = new Customer(); Set<Order> ...
0
votes
1answer
23 views

Failed to convert property value of type 'java.lang.Integer' to required type

I'm setting a many to many relationship, my join table JoinTable has a composite Pk with two keys, the problem is that when I try to persist my entity hibernate keeps saying that he can't convert java....
0
votes
0answers
9 views

Hibernate: try any solution but still “no persistent classes found for query class”

I'm beginner in Hibernate and I'm just trying to fetch some data from my DB via hibernate but I failed and I got this error : no persistent classes found for query class: from model.ItemClass I ...
0
votes
1answer
22 views

How to make a POST request that only updates the provided fields?

I'm trying to make a post request with json data that only updated the provided fields. Currently, when I don't provide a field in the request body, it is reset to the default value. when I send this:...
0
votes
0answers
5 views

configuring persistence provider info into LocalContainerEntityManagerFactoryBean in spring maven

I read that with newer versions of spring persistence.xml is not at all required and all the configurations can be made inside LocalContainerEntityManagerFactoryBean. Below is the major part of my ...
0
votes
0answers
17 views

Spring-Boot Query SELECT * FROM book (MANY to MANY rel with user) doesn't work properly

I am trying to return all the books from my database, but once I inserted values into the join table called COLLECTION (for solving the Many-to-Many Rel between BOOK and USER) the output I am ...
0
votes
0answers
10 views

Need to resolve org.springframework.core.convert.ConversionFailedException

When trying to get the Organisationinfo details I am getting below "exception": "org.springframework.core.convert.ConversionFailedException", "message": "Failed to convert from type [java.lang....
0
votes
0answers
19 views

Spring Boot: Get Object from @RequestParam

I'm trying to delete objects by clicking to delete button in this form: <form action="/applications/delete" method="get"> <input type="hidden" name="_csrf" value="${_csrf.token}"/> ...
0
votes
0answers
8 views

Can I mention a naming strategy specific to an entity class(Not at the entire project level)?

I am using "spring-boot-starter-data-jpa" for persistence. I want to define "Physical Naming Strategy" and "Implicit Naming Strategy" at the entity level. For example - In below code, naming strategy ...
0
votes
0answers
7 views

what's the purpose of below orm.xml in spring maven project

I am having orm.xml in my spring maven project which is being referred inside persistence.xml as below. <persistence-unit> . . <mapping-file>\META-INF\orm.xml</mapping-file> . . <...
0
votes
0answers
22 views

JpaRepository intermittently being found by java

I can run this program occasionally. Half of the time however the build cannot complete as the JpaRepository cannot be found. No errors are thrown in the code, and spring-boot-starter-data-jpa is in ...
0
votes
0answers
10 views

Can I have two persistence.xml files in my spring maven project

Is it possible for me to have two different persistence.xml files under META-INF eg. persistence-one.xml and persistence-two.xml and then somehow use <property name="persistenceXmlLocation" value=...
0
votes
0answers
12 views

How to set the parameter value of an annotation to be from a properties file?

I want to set the name parameter value of the @Table and @Column annotations to be from the application.properties file : @Entity @Table(name = "GACCCODE") public class Comptable { @Id @...
0
votes
2answers
42 views

ArrayList with more 10 items saved not ordered to DB

I receive List<MyDto> dtos with 14 MyDto and try to save it to the database. I receive List<MyDto> loop dtos and on each step: 2.1 -> map MyDto to MyEntity 2.2) -> save and flush ...
0
votes
1answer
25 views

JPA returning a nested object after creation - 500 Internal Server Error

I have my main object: @Data @Entity @EqualsAndHashCode(callSuper = false) @Table(name = MAIN_OBJ) public class MainObj { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name ...
0
votes
0answers
11 views

Using entityGraph with a Session

I have a method (let's call it FOO) that I use a couple of times. The result is an entity (let's call it MyEntity) that contains a lot of EAGER columns. In one scenario, I want this to fetch in a ...
0
votes
1answer
10 views

Hibernate CrudRepository native query not returning result with to_timestamp function

I am using oracle as db. I need to write a native query and store the result as list. The native query i am trying to run works perfectly using sqldeveloper tool. But when i try it with CrudRepository ...
1
vote
0answers
23 views

JPA Unexpected exception in beforeCompletion in Weblogic 12c

During a simple JPA managed transaction I fetch an Entity A from database using a Named Query and after few updates in it's state I merge the A entity again. The result of merge is a correct merged ...
0
votes
1answer
12 views

JPA Entity mapping SQL Function result to transient field

Instead of calling SQL function "manually" for every entity, is there any way to map its result to an entity transient field's ? @XXXX(call function with param ?) private int calculatedValue; Thanks
0
votes
0answers
9 views

Spring data jpa updatedOn getting changed for all the entities in OneToMany mapping while parent entity is saved

I am having a OneToMany Relationship in one of my Entity like below and using SpringDataJpa for data access layer. @Entity public class StudentSkillRecord { ... @OneToMany(cascade = ...
0
votes
0answers
9 views

how to switch providers in persistence.xml file in spring maven project

I need to switch my provider in persistence.xml based on the environment I am deploying the code. One of the env is having hibernate 5 and other is hibernate 4. So I need to switch between org....
0
votes
1answer
32 views

keeping copy of table day by day in the database

I want to copy all the data from original table to duplicate table at every day 12 o clock. If I do so whatever changes happen that should reflect in duplicated table..like if we add new row that ...
0
votes
0answers
17 views

Fetch comma separated HUGECLOB Column values in java

A list of comma separated ID's are stored in database column of type HUGECLOB, I'm trying to fetch this ID's by passing its primary key to fetch the records clobvalues corresponding to it, this is ...
1
vote
1answer
35 views

How to make JPA @query work with projection that has another projection in it

I'm trying to get projections works on @query in JPA with joined columns as an another project as well. Say, I have 2 entities: course and student and student can have many courses and the foreign ...
1
vote
1answer
21 views

springboot + JPA + MySql + Entity table generated uppercase

Have an issue where in SpringBoot 2.1.4 JPA using Hibernate to MySql is producing uppercase table names and I keep getting error that table not recognized for CONTENTSET. Real table name in MySql is ...
0
votes
0answers
23 views

How do you create a table that is named after a student id using jpa?

I am trying to create a student grade application where I am creating a table after each student, an naming it their student Id. The problem is whenever I create a student, it says that there is an ...
0
votes
0answers
31 views

Why repositories in jpa with mysql is returning nothing?

I have implemented an application in spring with jpa and mysql, but @repositories is not working, the method findAll returns Arraylist of size 0. application.properties: spring.jpa.hibernate.ddl-...
0
votes
0answers
16 views

Fixing weird characters in database with java spring query

I am using a news API to insert articles into a database. Whenever there are quotation marks or apostrophes it messes everything things up by putting these weird characters in there. I found queries ...
0
votes
0answers
10 views

Eclipselink to access various levels of associations

I am new to JPA/EclipseLink and I am building a restful interface to a database that contains state information about the execution of a program. The majority of the information that I need to make ...
0
votes
1answer
16 views

@JoinColumn gives error “column with logical name ID not found” in Hibernate 4

I am having below annotation on column in my entity class. @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "INQUIRYID", referencedColumnName="ID", updatable=false, insertable=false) private ...
0
votes
1answer
17 views

table can not be created in Postgres using jpa and hibernate

I try to generate tables in PostgreSQL using hibernate and jpa but that does not work, there is no error in the console. spring.datasource.platform=org.hibernate.dialect.postgres spring.datasource....
1
vote
2answers
19 views

JPA Foreign key in database, return object in project

I'm trying to connect my Java application to an existing database. The database contains Personen, who have 1 Graad and Locatie. The Graad.graadNumeriek is the primary key for Graad and Locatie has an ...
0
votes
0answers
27 views

JPA - Sql Server error: Cannot open database “Taijitan” requested by the login

I'm making a Java program that connects to an SQL Server database together with a small team. Their code runs succesfully, but whenever I try to launch the Java application, I get the error: Cannot ...
1
vote
1answer
23 views

How configure TomEE and JPA

sorry for my bad english, (Im french :-D). I want work with TomEE for JPA, but my configuration is bad i think. I receive a exception when i try to connecte to my database (Mysql). persistence.xml &...
0
votes
1answer
44 views

Union tables with spring data jpa

I have 2 tables one is Users and the other is UserGroup Having ManyToMany relationship , how can I union them into a single List with spring-data-JPA . ** don't want to use native Queries UPDATE: ...
0
votes
1answer
15 views

How to fix 'Unable to retrieve EntityManagerFactory for unitName null'

I am using Glassfish 5.0 with a Java Web App built in Maven framework. I have set up the Connection Pool and it is connected when you ping it. I have placed the persistent.xml file in src/main/java/...
0
votes
1answer
14 views

JPA NamedQuery not found

I'm trying to get a list of persons using JPA. Every time I run the code, I get "java.lang.IllegalArgumentException: NamedQuery of name: Persoon.getAllePersonen not found." I tried changing the ...
0
votes
1answer
31 views

How can I save ordered collection in JPA/Hibernate?

I have an main entity: @Data @Entity @Table(name = "MAINS") public class Main { ... @OneToMany(mappedBy = "main", cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = LAZY) private List<...
0
votes
1answer
39 views

Issue with JPA Sub Query

I start using QueryDsl 4 And I got this error java.lang.UnsupportedOperationException at com.querydsl.jpa.JPASubQuery.iterate(JPASubQuery.java:72) at com.querydsl.core.support....
0
votes
2answers
28 views

Spring Data Rest - Configure findBy path

With the following Repository: @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PeopleRepository extends PagingAndSortingRepository<People, String> { ...
0
votes
0answers
18 views

Spring db config with 2 data sources - the second connection throws HibernateException

I'm working on a Spring project that requires 2 data sources. One is to save user details and the others are to save product's information and other processes. I defined the database configuration as ...
0
votes
0answers
33 views

EclipseLink Lazy Property Throwing ConcurrencyException

I have the following schema (simplified and names changed): @Entity @Table(name = "fubar") @Inheritance(strategy = InheritanceType.JOINED) public class Fubar { @ManyToOne(fetch = FetchType.LAZY) //...
1
vote
0answers
20 views

Spring JPA Entity Graph and Self Reference occur N+1 query

I tried to use entity graph to avoid N+1 query, and it work as expected. It is different in self reference entity, though these code could get correct list, the N+1 query occurred. My question is ...
0
votes
0answers
18 views

How do I create a lookup table in my application using JPA and Hibernate?

I have an application that uses JPA and Hibernate. I have an entity called Person that has several fields that I would like to use lookup tables for. For example, there is gender, which [I believe] ...
0
votes
0answers
36 views

How to implement an arc in Spring JPA Hibernate [on hold]

Googled for this various ways and couldn't find anything like it. I have a contact point entity that relates, depending on type, to a phone number, an address, or an email account. One customer can ...
0
votes
2answers
31 views

Jpa ManyToMany relationships doesn't work

I have SpringBoot 2.1.3 + MySql 5.7 Database. I'm trying to do a ManyToMany relationship between 2 entities: @Entity @Data public class User { private String name; @ManyToMany(cascade = ...
0
votes
2answers
27 views

JPA update date timestamp

Whenever I insert or update the entity with JPA, I want to set the update date column on database systimestamp value. Note I want to use the time of the database node, not the time of the application ...
0
votes
0answers
16 views

Dynamically append (union) entities to a DTO projection

I have created a DTO entity, which main purpose is to serve as a projection for search results. The idea is that I have different searchable entities (Books, Magazines, Newspaper) and I have put them ...