All Questions
59,340 questions
0
votes
2
answers
53
views
Configuring Java Spring boot for testing w/ H2 and running w/ MySQL
I am setting up a microservice using Java Spring Boot. The application runs in a Docker container and connects to a MySQL database on the local machine. For testing purposes, I want to avoid the ...
0
votes
2
answers
29
views
Query polymorphic jpa entity using spring data specifications?
Let's imagine following entities:
@Inheritance(JOINED)
@Entity
abstract class AbstractCompany {
@Id
private Long id;
private String name;
//...
}
@Entity
class Company extends ...
1
vote
0
answers
34
views
hibernate flush mode configuration
using spring 3.2.1,
I found that the default flushModeType = Auto causing me issues as im trying to work on the object before persist it.
I tried to set the flushMode to COMMIT, but whenever it ...
0
votes
0
answers
16
views
Use PhysicalNamingStrategy on underlying DataSources of AbstractRoutingDataSource
i am using spring-boot with hibernate's PhysicalNamingStrategy together with a AbstractRoutingDataSource from spring and MS SQL Server. The goal is to have a dynamic schema switching for different ...
0
votes
1
answer
37
views
Hibernate 5: OneToOne without @Id
I have class Products which has:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "products_seq")
@SequenceGenerator(name = "products_seq", sequenceName = "...
0
votes
1
answer
25
views
An error is thrown because an entity field marked with the @Formula annotation is not contained in the resulting ResultSet
There is an entity that contains both regular and calculated fields via the @Formula annotation.
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "persons&...
0
votes
1
answer
20
views
ClassCastException for JPA query that tries to return the object queried in an inner SELECT statement
I have the following JPA query that attempts to find all the Children of a Parent object that fit under certain conditions, and then get only the first one of them under different partitions:
@...
3
votes
0
answers
40
views
Hibernate StaleObjectStateException After Upgrading to 6.6.3: Row was updated or deleted by another transaction or unsaved-value mapping was incorrect
Note: Before marking this a duplicate, please understand that I have gone through all the existing answers and issues but could not resolve the same.
I have two PostgreSQL tables: one for Product and ...
0
votes
0
answers
28
views
How to Create a Custom Hibernate SQL Dialect Compatible with Cloudera Impala (Hibernate 6.2.2.Final)
I am trying to create a custom Hibernate SQL dialect for Cloudera Impala. I'm using Hibernate 6.2.2.Final, and I need to ensure that the generated SQL for pagination uses the syntax LIMIT ... OFFSET .....
1
vote
1
answer
83
views
Why is my Scala project failing to find java.sql.Driver?
I have written a Scala+AKKA api using Scala 3. I then wanted to use Hibernate ORM to store data on the backend. I followed this guide: https://docs.jboss.org/hibernate/orm/6.6/introduction/html_single/...
1
vote
0
answers
27
views
Fix "org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.sqlExceptionHelper()" is null exception
After updating the Hibernate libraries. During startup, this exception is shown
java.lang.NullPointerException: Cannot invoke "org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(java.sql....
0
votes
0
answers
14
views
Hibernate Multitenancy: change tenant in session (discriminator column approach)
I am developing a springboot application which serves data for multiple tenants. To separate data between tenants I am using hibernates integrated multitenancy features for discriminator column-based ...
1
vote
2
answers
20
views
org.hibernate.MappingException: Unknown entity: org.example.Person
I am trying to save a record of Person class into mySql database using pure java and hibernate but I get this error. these are my classes. I appreciate any help why this error is raised.
With these ...
-1
votes
1
answer
27
views
Caused by: org.hibernate.type.SerializationException: could not deserialize Caused by: java.io.EOFException: null
I have a generic hibernate exception:
Caused by: org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.internal.util.SerializationHelper.doDeserialize(...
0
votes
0
answers
32
views
Hibernate 6 elementcollection fetching issue
I have following entities:
Template:
@Entity
@Data
@ToString
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@Slf4j
public class Template implements ...
0
votes
0
answers
21
views
Discriminator missing in query generated by Hibernate
I have a class with discriminator:
@Entity
@Table(name = "INSTR_UNDERL")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "discriminator", ...
-1
votes
0
answers
183
views
How to save hibernate FetchType.Lazy feature with Clean Architecture?
According to the clean architecture:
Your Entity objects should be plain old objects that have no dependencies on frameworks or databases or other complications.
As we see in Uncle Bob's diagram, ...
-6
votes
0
answers
61
views
Spring boot MVC project is not working due to status=404 Spring boot [closed]
I'm new to spring boot and built the MVC project but I'm facing the error:
Error:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat ...
-1
votes
0
answers
28
views
Hibernate Envers 5.6.15 mapping hbm ORM + envers annotation [closed]
In my project, I configured Hibernate 5.6.15.Final with HBM XML mapping for my classes and when to use Hibernate Envers on these classes by annotation.
On a class (Personne), I added @Audited(...
1
vote
2
answers
54
views
Java, spring, @Transactional
What will happen when we use entity.saveAndFlush() inside method that is annotated as Transactional in case of a rollback. I understand that we will synchronized changes inside persistence context, ...
0
votes
1
answer
30
views
What is the most efficient way to update a large list of objects using Spring and Hibernate?
I’m starting a small project using Java Spring Boot and Hibernate. It’s a simple game app involving a deck of cards. A deck can contain anywhere from a few hundred to a thousand cards. Each card is a ...
0
votes
1
answer
40
views
Error accessing column metadata in Hibernate 6
After migration from SpringBoot 2.7.18 to SpringBoot 3.4.0 and Hibernate 6 I have problem with automatic updating database structure.
When I set parameter
spring.jpa.hibernate.ddl-auto=update
I got ...
0
votes
1
answer
35
views
Making database work with a Dockerized Java Spring application
I would like to run my containerized Java Spring application which runs completely fine on my machine (of course, lol).
I have a problem with the JPA database connection.
What stumps me is that this ...
0
votes
1
answer
41
views
How to persist entities in @ManyToMany relationship with @EmbeddedId
I am using Spring Boot 3. I have 2 entities in @ManyToMany relationship: Meeting (table name is 'meeting') and Document (table name is 'document'), the relationship table is 'relation_document_meeting'...
0
votes
0
answers
24
views
BeanCreationNotAllowedException while shutdown multithreading app
I'm a newbie with multithreading, but I've a task. I need to parse web sites in async mode.
I have next class and use ForkJoinPool:
@Service
@RequiredArgsConstructor
public class PageIndexingService {
...
1
vote
0
answers
45
views
Dropwizard - new entities not commiting
We have a thread that queries external systems by clients. It receives a JSON array containing client information like id (which our system calls "customId"), name, phone, etc. The array is ...
0
votes
0
answers
53
views
Execute SQL function with jakarta.persistence.Query throw commit error
what I want: I need to execute a SQL function (very large) with jakarta.persistence.Query.
what I do:
@Transactional
public int executeRunFunctions() {
Query query = entityManager....
1
vote
1
answer
52
views
Mapping the timestamp data type to PostgreSQL in a query
I have a problem, maybe someone has encountered this, I can’t make a request that can work with null correctly.
I have an entity in the database with a column updateAt.
@Data
@Entity
@Accessors(chain =...
1
vote
0
answers
71
views
Hibernate Envers 6.2.6.Final throws REVINFO_SEQ.nextval sequence not found
Hi I migrated my project from Spring boot 2.7.18 to 3.2.11 and Hibernate and Hibernate Envers from 5 to 6.2.6.Final.
With Spring boot 2.7.18 and Hibernate 5, services were running without any issues ...
3
votes
1
answer
2k
views
Spring Boot 3.4.0 lets integration tests with JPA/Hibernate fail
We have updated from Spring Boot 3.3.6 to version 3.4.0. Now our integrationtests (Annotation @SpringBootTest) with Hibernate/JPA interactions (we're using spring-data-jpa) in it fail suddenly.
@Test
...
0
votes
0
answers
38
views
Hibernate Primary Key and Foreign Key Size Mismatch in MySQL
I’m working on a project where I need to set a composite primary key for a Session entity using Hibernate and MySQL. However, when I define the Session entity as follows, Hibernate generates a table ...
0
votes
0
answers
36
views
Does static method impact Spring SQL transactions?
I noticed that if I have a method annotated with @Transactional, which calls a static method, which results in database calls, Spring will create two different hibernate sessions and use two different ...
0
votes
0
answers
81
views
Hibernate 6.6 fails if there is a generic @Id in a @MappedSuperclass
Having changed org.springframework.boot:spring-boot-starter-parent from 3.3.4 to 3.4.0 (and implicitly Hibernate from 6.5.3.Final to 6.6.2.Final), I faced java.lang.IllegalArgumentException: expecting ...
0
votes
2
answers
77
views
spring data jpa ORA-01795: maximum number of expressions in a list is 1000 [duplicate]
@Query("SELECT DISTINCT rh FROM RoleHead rh, RoleDmdLine rl"
+ " where rh.id=rl.id" + " and rl.id in (:roleListId)"
Iterable <RoleHead> findAllByLıne(@param("...
0
votes
1
answer
25
views
JPA how to add a join chain on one Entity?
class A{
@ID
private Long id;
@ManyToOne
@JoinColumn(name="bid",referencedColumnName="id")
private B b;
}
class B{
@ID
private Long id;
@ManyToOne
@JoinColumn(name="cid&...
-1
votes
1
answer
64
views
Getting error in spring while saving entity
I am getting error while saving an User entity in spring using jpa/hibernate. Below is my User entity class
@Entity
@Table(name = "user")
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
...
1
vote
0
answers
56
views
Using community dialects from Hibernate core
Context - I need to run Hibernate core tests on 6.x version with PostgreSQL92 dialect. Starting Hibernate 6.x version, legacy dialects were moved to hibernate-community-dialects subproject, which is ...
0
votes
0
answers
26
views
Foreign key must have same number of columns as the referenced primary key with Map<String, Object> [duplicate]
I have class User:
@Entity
@Table(name = "user")
public class User extends HibernatePersistentObject implements Serializable
in which I am trying to get preferences for user:
@...
0
votes
0
answers
66
views
Rollback does not work for standalone JTA with Narayana 7, Spring 6 and Hibernate 6
I am trying to use Narayana JTA (standalone) for integration tests using Spring 6, Hibernate 6 and Narayana 7 jars. There are two XA datasources for 2 different oracle databases.
I have an integration ...
0
votes
2
answers
42
views
Using an @Entity in an @IdClass as @Id
I have an entity that looks like this
@Entity
@IdClass(AId.class)
class A {
@Id
private String userName
@Id
@NotNull
@JoinColumn(name = "location_id", ...
2
votes
0
answers
23
views
Hibernate @Filter Not Working as Expected
I am trying to define @Filter on Entity,and it's not working on my test code
This is my entity:
@Entity
@FilterDef(
name = "tenantFilter",
parameters = [ParamDef(name = "...
0
votes
0
answers
64
views
Hibernate ObjectNotFoundException: No row with the given identifier exists
I have 3 tables:
instances
instance_members
instance_invitations
where "Instance" has an @OneToMany relationship to "InstanceMember" and "InstanceInvitation" and the ...
0
votes
0
answers
23
views
How to get a query result in List<Object[]> type in orm.xml with JPA?
I'm trying to get a query result in List<Object[]> type by a named native query, which is defined at the orm.xml.
When I run the code, it gives me an error as following:
Cannot create ...
0
votes
0
answers
18
views
How to Handle Missing Data in LEFT JOIN for Custom Fallback Message in JPA Query?
I'm building a Spring Boot application where I need to fetch data from an AuditLog table. This table is connected to several other entities through LEFT JOIN, and one of those entities is ...
0
votes
1
answer
58
views
Error "detached entity passed to persist” when selecting data via the repository, I don't understand
I'm having trouble updating an entity (Formation) in a ManyToMany relationship with another entity (Intervenant).
My integration test fails because of the following error:
org.springframework.dao....
0
votes
0
answers
34
views
Relationship between two entities through partial primary keys
In my Spring Boot project I have the following JPA entities:
@Entity
@Table(name = "T1", schema = "t1_schema")
@Data
public class T1Entity {
@EmbeddedId
private T1Id id;
...
0
votes
1
answer
42
views
EntityManager.close not releasing connection back to the pool
I have an old spring application that uses the following configuration for Spring JPA and Hibernate:
<bean id="myEmf" class="org.springframework.orm.jpa....
0
votes
1
answer
43
views
Java Hibernate. OneToMany collection problem
I have two entities:
@Setter
@Getter
@Entity
@Table(name = "Task")
@NoArgsConstructor
public class TaskEntity implements AbstractEntity {
@Id
@GeneratedValue(strategy = ...
0
votes
1
answer
31
views
Unknown Entity annotated with @MappedSuperclass
I have parent class
@MappedSuperclass
public abstract class CommonDate extends HibernatePersistentObject implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "...
0
votes
1
answer
50
views
Filter associated entity on one query with hibernate and jpa?
I have question how to filter associated entity for example I have entity A
public class A {
private Long id;
@OneToMany
private List<B> bList;
}
and entity B:
public class B {
private Long ...