Questions tagged [jpa]

14695 questions
-1

votes
0

answer
27

Views

Spring Data (JPA) does not work with dates?

something weird happens here ... And I want to gel all fields using this query using JPQL or Spring JPA, but both methods return 0 fields. SELECT * FROM puntuacion WHERE id_tienda = 1 AND fecha BETWEEN and ; I have this entity, look at 'fecha' property This is the code ... (I'm using Spring Boot,...
Guru_Clef
2

votes
1

answer
28

Views

JPA changes on DB not written before method finished

I have a @Stateless-Bean which performs some Database operations in a single method public void doOperation(){ User u1 = createNewUser() User u2 = createNewUser() User updated = mergeUser(u1,u2) // just as an example // should write to database now! otherBlockingOperation() } However the changes ar...
greedsin
0

votes
0

answer
3

Views

spring boot not fetching data from external oracle database configured

I want to configure oracle database with spring boot2. I have developed the dao layer code and unit tested with embeded H2 database successfully. But now when i provide the datasource configuration details in applicaiton.yaml file, it is not able to retrieve the data from the external oracle databas...
Reese
0

votes
0

answer
4

Views

MongoRepository @Query Failed to parse string as a date

First of all, my issue is searching Collecttions in MongoDB via Spring JPA (MongoRepository). My Object: { '_id' : ObjectId('5c78e1f447f39c2eacb229d7'), 'lab' : 'xxx', 'type' : 'Holiday', 'description' : 'Lunar New Year', 'start_date' : ISODate('2019-02-04T02:37:42.152Z'), 'end_date' : ISODate('2019...
Nam Nguyễn
0

votes
0

answer
5

Views

Spring boot async

I have one spring service it will save entity and I call async after save that entity in that async service some time I am getting entity not found exception... I have pass entity as parameters in async call but still getting same exception please help me
Sabbirali
0

votes
0

answer
3

Views

Duplicate data in the child object

I use spring boot 2.1 with spring data jpa and hibernate @Entity public class Factories{ @Id @SequenceGenerator(name = 'factories_id_seq', sequenceName = 'factories_id_seq', allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = 'factories_id_seq') private Integer id; @O...
robert trudel
1

votes
1

answer
2.3k

Views

Try to use C3P0 with Hibernate

I'm using JPA and have a persistence.xml with the following configuration: org.hibernate.ejb.HibernatePersistence The problem is that when i try to initialize my tomcat i got the following error: 691 [Thread-2] ERROR org.hibernate.connection.ConnectionProviderFactory - Could not instantiate connecti...
Shelly
1

votes
1

answer
1.3k

Views

Use cirteria builder on embedded object

I am trying to use @Embeddable with CriteriaBuilder to filter results of a parent Entity based on the embedded property. I use Eclipse Link to generate the Metadata classes. here is the embedded class/entity: @Embeddable public class Stamp implements Serializable { @Basic() @Column(name = 'stamp_yea...
Gadi
1

votes
0

answer
5

Views

Spring cloud sleuth not appending keys to Hibernate query logs

When I am using spring cloud sleuth, I am observing that it is appending application name and key details for all the application logs. But this is not happening for Hibernate logs or jpa queries. Is there any way to achieve this using sleuth
Async Code
1

votes
1

answer
554

Views

JPA Hibernate select distinct over @ElementCollection and compare

I am using Hibernate with JpaRepositories. The relevant part of the Entity class is: @Entity public class Person { //.. id and other attributes @Column(name = 'function') @ElementCollection private Set functions; // .. getter setter } I needed to change my Entity class from having only one function...
Coco
0

votes
0

answer
5

Views

How to force Postgres to calculate MAX(boolean) with JPA/Hibernate?

With normal Postgres sql i am able to get it values , but with jpa / hibernate , I am facing an issue . is there anyone who can help me on this .
0

votes
0

answer
4

Views

Shared Primary Key between two Entities Not Working

I have created two Entities namely Teacher and Detail, the code snippet is shown below Teacher.java @Entity @Table(name='teacher') public class Teacher implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name='id') private long id; @Column(name='name') private S...
Arul Suju
1

votes
1

answer
2.6k

Views

JPA CriteriaBuilder find entity which has elements with certain attributes in collection

I have an entity which contains a list of elements and now I want to search over attributes of these elements. This constraint should be 'and' connected. Please see these simple example: @Entity public class Parent { @Column @Enumerated(EnumType.STRING) private City city; @OneToMany(...) private Li...
1

votes
2

answer
1.1k

Views

Aggregation relationship via JPA annotations

I am trying to establish the aggregation relationship between two Java classes through JPA annotations in order to persist them into a database. public class Ticket { private String ticketNo; private Date releasedDate; private boolean printed; } public class Discount { private String percentage; p...
julianfperez
0

votes
0

answer
5

Views

Getting problem while adding dependency jar to other project while dd curd operatoins

I have dependent jar for other project and i am doing curd operations in both the projects while calling method after adding the jar to another in the line of curd operation i am getting response as null that is the repository w.r.t tp dependent jar is not instantiating and showing null in response....
Rak
0

votes
0

answer
5

Views

Why jpa are searcing two duplicates records while joining two pojos bidirectionally

jpa select query returning some duplicate records and not traversing some records. I have Two pojos Student and Class. STUDENT POJO: @SuppressWarnings('serial') @Entity @Table(name='model_2', schema='vahanpgi') public class Student implements Serializable { @Column(name='m2_id') private String stuId...
user9864064
0

votes
0

answer
3

Views

jHipster project: Call a stored procedure involving several tables

In my jHipster project i have several entities: client, purchase_agrement and visit client: id name purchase_agreement: id client_id jhi_date sum visit: id jhi_date client_id I need to filter visit and purchase_agreements between two dates and created stored procedure: DELIMITER // CREATE PROCEDURE...
harp1814
1

votes
3

answer
63

Views

How to get Entity from RestController depending on mapping URL

I have MyEntity class: @Entity @Table('entities) public class MyEntity { @ID private String name; @Column(name='age') private int age; @Column(name='weight') private int weight; ...getters and setters.. } In @RestController there are 2 @GetMapping methods. The first: @GetMapping public MyEntity get(...
Donatello
1

votes
0

answer
10

Views

Spring Boot - Pagination for Many-to-Many Relationship with extra Column

I can't find a clean and simple way to do pagination when using a many-to-many relationship with an extra column. My model looks like that: I have a user and a product model. Each user can consume n products. Each consumption will be stored in an extra table, because I want to store extra informati...
Leonleon1
0

votes
0

answer
10

Views

Why does @Query not execute native sql in my spring boot application

So today I am creating a spring boot web application, I was trying to execute my own custom queries instead of the typical CRUD styles. I was creating something to delete by name rather than ID, so it required some native sql. Things quickly got out of hand. Here is the code. Alien.java: @Entity pub...
Nicholas Begg
0

votes
0

answer
10

Views

Unique index or primary key violation when persist a new element

I am creating an application and when saving a new item I get the following error: 2019-03-17 00:05:09 WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 23505, SQLState: 23505 2019-03-17 00:05:09 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - Unique index or primary key violation: 'PUBLIC.PRIMARY_KEY_...
EduMarques29
0

votes
0

answer
2

Views

Error The persistence xml file [META-INF/persistence.xml] was not found JPA EclipseLink Netbeans

I'm using JPA and EclipseLink (2.7.4) in Netbeans 10 (JDK 11). I recently switched to using EclipseLink 2.7.4 instead of 2.4 as it was giving me issues with JPA. Now, I'm getting this error when building: Note: Creating non-static metadata factory ... Note: The persistence xml file [META-INF/persist...
The Fox
1

votes
3

answer
311

Views

Spring data query dsl how to add order by?

I'm new to queryDsl,I'm working on Spring data query dsl to make a dynamic filter ,I use the interface : QueryDslPredicateExecutor so I can filter data using different entity fields ,now I want to add an order by to my query based on an BooleanExpression This my code : QPersonData _personInvento...
E2rabi
0

votes
1

answer
17

Views

How can I prevent insert and allow only update of my object using spring-boot?

I know that save() will insert my object if its not already present in db and will go for update if its already present (object identified using the primary key field). I have tried a code as follows public void update() throws UpdateFailedException{ boolean b= findByPK(); // checking if the entry i...
JITHIN
1

votes
2

answer
1.7k

Views

Spring+Hibernate: Inserting mutliple records and @Transactional

I have an application built on Spring+Hibernate. I'm trying to insert data into the database from a list of entries in a file. The basic idea is to insert all the records which have valid data and log an error report for all the entries that haven't been inserted. A service class, which is @Transac...
dora
1

votes
2

answer
496

Views

Any way to inherit an entity which is not @MappedSuperclass?

Let's suppose I have a JPA entity: @Entity @Table(name = 'PARENT') public class Parent { // ... } Is there any way, maybe Hibernate-specific, to create subclass of Parent in a separate table? @Entity @Table(name = 'CHILD') public class Child extends Parent { // ... } The main idea is to have set of...
Alex Salauyou
0

votes
0

answer
4

Views

Saving a entity with multiple lazy-associations

I have a scenario where I need to save an entity with multiple associations but I don't want to retrieve these associations if not needed. I will try to give a simple example: Entites: public class Foo { private Long idFoo; private String defaultMessage; /* Getters and Setters Ommited */ } public...
marcellorvalle
1

votes
2

answer
953

Views

How to set Hibernate bulk_id_strategy in spring boot application?

Hibernate is generating temporary tables for TABLE_PER_CLASS inheritance but the prod. oracle user does not have those create table priviledges and therefore that approach is not an option for our project. Hibernate Version 5.2.8 is said to resolve that issue. We updated our pom.xml accordingly to...
desperado06
1

votes
2

answer
14.1k

Views

Schema-validation: missing table [game]

I think it may be possible dupplicate of this: Schema-validation: missing table [hibernate_sequences] but I can't figure it out. So in my application.properties file I have this option: spring.jpa.hibernate.ddl-auto=validate and I receive this error: Schema-validation: missing table [game] Why I am...
Rares
1

votes
2

answer
7.8k

Views

java.sql.SQLException: ORA-28040: No matching authentication protocol

My Application uses JSF Primefaces 5.0, JDK 7, Oracle Database 12, Tomcat 8. It works fine when I deploy my webapp war from within Eclipse on it's integrated Tomcat 8 server (all this happens on Maven build). But when I deploy manually the same war on Tomcat 8 server(using tomcat manager deploy UI)...
Mahantesh H
1

votes
2

answer
279

Views

Using @Column and @Formula in Hibernate at the same time

I've got a POJO and currently I'm getting a value from a single column. However, I'm moving to retrieve it using Hibernate @Formula (I select the latest record from another table). I want to go softly in order not to break anything. So what I want to do is something like this: class SomeDto { privat...
Dmitry Senkovich
1

votes
2

answer
897

Views

Spring data repository not found at compile time

I am trying to use Spring data and repositories in a Spring Boot application, but I have an error when compiling the project. Here is my Entity : package fr.investstore.model; import javax.persistence.Id; ... @Entity public class CrowdOperation { @Id @GeneratedValue(strategy=GenerationType.IDENTITY)...
Romain Guidoux
1

votes
1

answer
1.2k

Views

Spring JPA Repository merge instead of save

Could you help me with JPA Repository? During update request and using POST method - I need to save only fields that I sent into my POST body. But if I didn't write it into body JPA Repository set is as null (DB MySQL, default null). Please look the picture. If I don't send in bode airport code it...
Eugene Shamkin
0

votes
2

answer
17

Views

How to avoid redundant data (list fetching) in JPA One To Many mapping (Two One to Many relation in same model)?

I have three Model. BookingDetail have One To Many relation to both LookupFoodItem and LookupFacility model.In my database there is 4 LookupFacility record and 4 LookupFoodItem record. When I'm fetching BookingDetail one record there should be 4 LookupFoodItem record but I found 16 record which is r...
Mijanur Rahaman
0

votes
0

answer
10

Views

JPA entities with json binding (JSON-B) using @JsonbTransient

I have many JPA entities, which have 1..N relations. I would like to serialize/deserialize the entities to/from json format with JSON Binding (JSON-B). Here is simplified sample code: public class Parent { @Id private long id; // 1 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappe...
Mikko Tuominen
1

votes
3

answer
420

Views

Errors while executing Select Statement using JPA

I am trying to use Select Query with JPA but i am getting some error: This is my CountryDto.java file @Entity @Table(name = 'COUNTRY') public class CountryDto { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name='COUNTRY_ID') private int Country_Id; @Column(name='COUNTRY') privat...
user15
1

votes
1

answer
869

Views

Native query as variable

Is there any way to pass a native query as a variable? I want to use something like that @Component public interface MyRepository extends JpaRepository{ @Query(nativeQuery = true, value = query) List find(String query); }
mariusz2108
1

votes
1

answer
166

Views

Entity Manager always null

I'm developing a J2EE application, but I've got a problem where my _entity_manager is always null. I checked my code, my pool, I restarted the EJB, and I restarted the GlassFish server, but I am still having the problem. persistence.xml: test Resource injection line: @javax.persistence.PersistenceC...
Thomas B.
1

votes
1

answer
95

Views

Servlets , JSP, JPA - Property Not Found Exception

I'm writing my first bigger app and I have one issue, my code below: InitDB.java public void requestInitialized(ServletRequestEvent arg0) { EntityManager em = DBConfig.createEntityManager(); BooksDAO booksDAO = new BooksDAO(em); CategoryDAO categoriesDAO = new CategoryDAO(em); ServletRequest req...
Kamil W
1

votes
1

answer
391

Views

Transaction didn't get roll back after a exception

I'm running a jpa/spring-mvc project and in this code : @Autowired private GenericDao modif_dao; .... @Transactional public void save_ao( ... ) throws ParseException, UnsupportedEncodingException { modif_dao.delete(ao.getAoModifications()); modif_dao.create(new AoModification( new SimpleDateForma...
Youssef

View additional questions