Questions tagged [hibernate]

Hibernate is an object-relational mapping (ORM) library for the Java language enabling developers to utilize POJO-style domain models in their applications in ways extending well beyond Object/Relational Mapping.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

Alternative to deprecated AuditReader#getCurrentRevision method

I am migrating a java application from Spring Boot 1.5 to Spring Boot 2.2.3 and this involves upgrading Hibernate/Envers to 5.4.10.Final. The existing code calls AuditReader#getCurrentRevision(Class ...
0
votes
0answers
17 views

JAVA @Query trying to look for non-existing table, corresponsing to Entity class-name

I've got a dependant service, who's sole purpose is to query every once in a while few tables of several kinds of customers we have (rejected, pending, etc) and create leads from them to send to our ...
0
votes
0answers
14 views

Hibernate - rewrite legacy createCriteria

I have a following Hibernate code: return (Post)sessionFactory.getCurrentSession() .createCriteria(Post.class) .add(Restrictions.eq("title", title)) ...
0
votes
0answers
12 views

Selecting specific columns in many to many relationship with JPA

I have to Models for two Entities in Database. Model User and Model Role. These two entities have a many-to-many relationship. In the model files I have class User.java: @Entity @Table(name = "User") ...
0
votes
0answers
14 views

Unable to create initial connections of pool, Unable obtain JDBC Connection errors with springboot data jpa springboot version 1.5.8.RELEASE1.5.8

I have springboot data jpa application where I am creating two data sources. I am getting this error when my application is booting up. 1. org.apache.tomcat.jdbc.pool.ConnectionPool init SEVERE: ...
2
votes
1answer
31 views

Spring Data upsert by equals

I want to update/insert an entity, depending not on primary key but on equals: @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true) @Builder class Alert { @Id @Basic(optional = ...
0
votes
0answers
29 views

JPA lazy loding is not working in one to many

JPA lazy loading is not working in @OneToMany(fetch=FetchType.LAZY association. Only need to load parent object without child object Parent Object - Emp @MappedSuperclass public ...
-1
votes
0answers
28 views

How to fix SqlException error --> JdbcTemplate

I am creating web-app which have functionality "sql interpreter". Select from tables / drop tables / delete rows / update rows Those operations works well and if user will insert something wrong into ...
0
votes
1answer
19 views

required a bean of type 'org.hibernate.SessionFactory' that not found

I am trying to develop a CRUD web application with Spring Boot. I use Hibernate for my DAO part. When I try to lunch my main app, I received the following error message : Interface Cliente DAO : ...
2
votes
1answer
26 views

Foreign key mapping to Embeddable class

I am using Hibernate to join Entity1 to Entity2 where Entity2 have a composite primary key. Entity2 contains 2 columns id and type public class Entity2 { @EmbeddedId private Entity2PK id; } @...
0
votes
2answers
30 views

Can't generate DDL creation script with Spring Boot

I am trying to generate DDL creation script with Spring Boot, and found somewhere that this configuration is supposed to do it: spring: jpa: properties: javax: persistence: ...
1
vote
0answers
22 views

Foreign key the extended ID

I have 3 tables that extend a class along with it's properties Is it possible to make the extended id a foreign key and the principal id a primary key,i tried with @PrimaryKeyJoinColumn([email protected]
0
votes
0answers
13 views

Resolves Hibernate JsonIdentifyInfo with full information for Json format

i have an entity with the annotation @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id", scope = Staffs.class) If I get my Json file it looks like [ { "...
-1
votes
1answer
28 views

How to catch exception from createNativeQuery? [closed]

I have problem with handling exception. I need to execute native queries which can return some metaData for me. Here is my way to execute native query: SessionFactory hibernateFactory = someService....
1
vote
1answer
11 views

How to SELECT partial entity, and then use the entity update the entity in the database?

I have an entity class with about 70 columns. The table may have around 200,000 rows. I want to update just one of the columns for all the 200,000 records. Normally I would retrieve all the entities, ...
0
votes
3answers
27 views

Hibernate Cascade DELETE OneToMany does not work. Referential integrity constraint violation

I have a class Webtoon that contains a list of Episode. It is a one direction relation. @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER) @CollectionTable(name= "list_of_episodes") ...
0
votes
1answer
26 views

Flush the session in Grails 4.0.1

In past projects which were using previous versions of Grails/Hibernate I have used in services funciton: private void cleanGorm() { def session = sessionFactory.currentSession session.flush()...
4
votes
0answers
45 views

Java “Error executing DDL via JDBC Statement” when using Docker [closed]

I have a spring-boot application which must be loaded to Docker. I ran "mvn package" and created a jar. I created the Dockerfile file and the Docker-compose.yml file, configured them, and everithing ...
2
votes
1answer
27 views

How to get values from logs into java list? <hibernate>

Is this possible to take that values from console: and save them into java list/map? I printed that logs in that way: logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.type=TRACE ...
0
votes
0answers
22 views

How do I configure Spring/Hibernate to store localDateTimes with seconds precision?

I want LocalDateTimes that are coming in from requests to be formatted in a specific format ("dd-MM-yyyy HH:mm:ss"). The below (Kotlin) code takes care of that. The problem is that comparisons between ...
1
vote
1answer
24 views

Set UpdatedTimeStamp in a particular TimeZone in Spring Boot Hibernate for Postgres

I have an entity that stores a last updated date like this @Entity @Table(name = "counter") public class Count { @Id @Column(name = "uniq_id") String uniqId; @Column(name = "amount") ...
1
vote
0answers
24 views

JPA Criteria Order by FIELD

I am trying the order the data by field e.g Query - select * from user where (location = "%loc%" and role = "TECH") order by field (department, "ELEC", "MECH"); I created custom Order class for ...
0
votes
1answer
20 views

Hibernate- OneToMany Relationship

@Entity @Table(name= "employee1100") public class Employee { @Id @Column(name="eid") @GeneratedValue(strategy=GenerationType.AUTO) private int id; @Column(name="ename") private String name;...
0
votes
2answers
26 views

Could not instantiate bean class annotationsessionfactorybean

*Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in class path resource [resouce/springXML.xml]: Instantiation of bean ...
0
votes
0answers
19 views

How to filter a field in two conditions (currency case) in Spring Boot Hibernate

I have created a really long specification for my filter in my Spring Boot project in which there is a "Price" field represents the price of the product in two currencies. In other words, the price ...
0
votes
0answers
37 views

random constraint behaviour

I try to insert 1 value into table 'beleg_kopf', then inserting 1 value into 'beleg_kunden' and then inserting 1 to n values into 'beleg_positionen'. Foreign keys can be seen in the SQL code. When my ...
0
votes
0answers
24 views

How To Make a Non-String Field Required in Spring MVC

I have done @OneToOne Mapping on customerSSN field in the above example and also used a custom converter to achieve this. Now, i know that the @NotNull and @Size annotation won't work on this feild so,...
0
votes
0answers
29 views

kotlin - using higher order functions in with hibernate

I ran into a weird issue when I was playing with kotlin+spring+hibernate, I’m pretty sure this is what’s causing problems: inline fun <reified T : Enum<T>> generateGetter(unknownValue: T):...
0
votes
0answers
34 views

Add opening hours to restaurant java spring one to many relationship

BACKEND: here is my backend RestraurantService class CreateRestaurantclass which has a list of OpeningHours: public void createRestaurant(@Valid RestaurantCreateRequest restaurantCreateRequest){ ...
0
votes
1answer
36 views

How to print native query into console?

I am creating web-app to database management. One of functionalities is "interpreter SQL". Here is my code which is used to execute queries: Example 1 1 public String executeSQL(String[] split){ 2 ...
0
votes
1answer
45 views

JUnit Test: NoSuchBeanDefinitionException: No qualifying bean of type

I'm getting the following exception: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.servlet.http.HttpServletRequest] found for ...
0
votes
1answer
15 views

How to apply hibernate annotations to the child class of abstract class

I have an abstract class named Staff. Instructor and Lecturer are the derived classes from the Staff superclasses. I need to use hibernate annotations into the Instructor and Lecturer classes. Staff....
0
votes
1answer
23 views

Java 11 Hibernate Validator module not found error

I am having trouble migrating my project to Java 11 from Java 8 with Hibernate validator. I get the following error while attempting to build my project with maven: [INFO] --- maven-processor-plugin:...
0
votes
0answers
10 views

jbpm spring-boot Postgres Datasource Table Creation exception

I generated default project from https://start.jbpm.org/ and then modified internal H2 database to Postgres. I am using the following config for spring-boot application.properties jbpm.executor....
1
vote
4answers
65 views

Why I'm getting an error when I'm trying to insert a new object in db?

My scenario is as follows A User can have a list of Track, corresponding to it, the Track entity contains a user id.(@OneToMany) Whenever a new track is created, the list of tracks will be updated. ...
0
votes
0answers
15 views

Hibernate.search.default does not exist

I am trying to configure hibernate, so that it uses "local-heap" as the default directory provider, and the docs state to set hibernate.search.default.directory_provider to local-heap (which I am ...
0
votes
0answers
21 views

Hibernate: creating a unique GenerateValue for each relational record when inserting collections

I'm using Hibernate to insert entities like so: I'm inserting a single post entity which owns a collection of comment entities. I'm trying to insert a new post with two new comment entities, but am ...
0
votes
1answer
32 views

request generated by hibernate non conform to written request

there is something crazy that's happening to me. I work on a spring boot hibernate project that was generated with Jhipster. I made a simple JPQL request that is like the following select item from ...
1
vote
2answers
39 views

How to map custom data structures to bean entities with JPA/Hibernate?

We have a (possibly large) custom data structure implemented in Java (8+). It has a simple and optimal API for querying pieces of data. The logical structure is roughly similar to an RDMS (it has e. g....
1
vote
1answer
38 views

Casting expression's result in criteria api

I have this code: CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder(); CriteriaQuery<Integer> criteriaQuery = criteriaBuilder.createQuery(Integer.class); Root<Teacher> c = ...
0
votes
1answer
18 views

Query new Object List

I need some query to get new objects. My result object is: @Getter @Setter @NoArgsConstructor public class MegrendelesNap { int year; int ora; public MegrendelesNap(int year, int ora) { ...
0
votes
0answers
24 views

Spring jpa transactions in same session not working

This is my code sample saveClaim(){ Claim claim = new Claim(); claim.setId(1); claim.setName("Jhon"); claim.valid(true); myrepo.save(claim); //first transaction boolean response = ...
0
votes
0answers
32 views

How to pass values of mulitple rows of each objects from jsp to the controller and save them to the mySQL data base using hibernate in Spring Boot

Two model classes were created .One for base class and the other one for taking the list of objects of the base class as a list .But none of the objects are passing from the jsp to the controller and ...
1
vote
0answers
28 views

How to use JPA or JDBC to call specific PL/SQL function using REF CURSOR

My problem is that I want to call PL/SQL function in @PostConstruct method in Spring Boot. This function returns information about tables in a database as you can see above: CREATE OR REPLACE ...
1
vote
1answer
34 views

How to ignore LAZY types dynamically on SpringBoot app?

I have a class: @Entity @Table(name = "restaurants") public class Restaurant extends AbstractNamedEntity implements Serializable { @OneToMany(fetch = FetchType.LAZY, mappedBy = "restaurant") ...
0
votes
0answers
31 views

JPA Hibernate uses @NotNull Annotation on Getter despite using @Access(value=AccessType.FIELD)

I have an Entity that uses @Entity @Table( indexes = {@Index(name="URL_PARAMETER_INDEX", unique = true, columnList = "urlParameter")} ) @Access(value=AccessType.FIELD) public class EntityA ...
2
votes
0answers
18 views

JPA/Hibernate transaction issue

I wish I could generate primary key with the option TABLE and I don't understand why the transactions doesn't works. Here is my environnement (this is an example, not the true application, but it ...
0
votes
0answers
29 views

Domain entities using Hibernate entities?

In my current struggle with DDD in a Spring Boot application,I'm in an impasse. I know my domain entities should not have any connection with the infrastructure layer (Where the Hibernate entities ...
0
votes
2answers
64 views

Cannot convert value of type 'java.lang.String' to required type

I have REST server on Spring-boot 2.2.1 connected with mysql and JavaFX client using Spring-web 5.2.3. I would like to send http request from client to server. For method GET works great, but for POST ...
0
votes
0answers
35 views

Issues while replacing hibernate create criteria with JPA criteria

In my project we have extensively used hibernate criteria, which has now deprecated in newer releases. I tried to replace the same with the JPA criteria but faced some below mentioned issues: Select ...