512 questions
0
votes
1
answer
60
views
IdentifierGenerationException when persisting @OneToOne relationship with shared primary key
I am working with a MySQL database and using Hibernate (6.6.0.Final) without Spring. My schema involves two tables, film and film_text, which are implicitly related in a one-to-one relationship. The ...
1
vote
1
answer
3k
views
@GeneratedValue doesn't support with not Id column after upgrading to springboot 3.2.4
I was upgrading springboot 3.1 to 3.2.4 which uses hibernate 6.4.4.Final.
I am getting the below error while building the mvn project-
Error creating bean with name 'entityManagerFactory' defined in ...
0
votes
1
answer
1k
views
What is behavior when overriding method annotated by @Transactional in Spring
There are 'duplicate' questions regarding spring annotation 'inheritance', with resolute, but probably incorrect answer: NO(not inherited). Update: it's provably wrong.
Annotations aren't inherited ...
0
votes
1
answer
116
views
@Formula annotation gives an exception when entity is saved in RepositoryItemWriter
I have an entity which is used by RepositoryItemWriter in a step and RepositoryItemReader in next step. I want to populate a value in entity class when it is loaded in the second step. that value is ...
0
votes
1
answer
1k
views
Hibernate 6 Could not resolve org.hibernate.common:hibernate-commons-annotations
Upgraded my Hibernate dependencies from 5.6.11.Final to 6.1.7.Final, migrated to the jakarta packages and my project will no longer gradle build because it cannot locate org.hibernate.common:hibernate-...
1
vote
0
answers
370
views
Hibernate @CreationTimestamp filed is null on findById()
Here is a quick scenario.
Environment
Java 8
Spring boot 2.7.5
Hibernate 5.6.12.Final (comes with spring data JPA)
My Entity
@Entity
@Getter
@Setter
@Table(name = "test_entity")
public ...
1
vote
0
answers
107
views
Problem using custom PropertyAccessor implementation with annotations
I've a custom implementation of PropertyAccessor that only works if I declare it in the XML mapping file, but not when using field annotations in POJOs).
I try the following:
With hibernate-core (4.2)...
1
vote
1
answer
395
views
How to map ID column from @SecondaryTable
I have an entity like this, and I am failing on mapping the ID column of the second_table to chId of my entity, but in the case of dep_id mapping works fine
Stacktrace is:
nested exception is org....
0
votes
1
answer
148
views
After Hibernate upgrade, the PropertyValueException is thrown
after Hibernate upgrade 4.3.11.Final to 5.0.12.Final my test has stared failing with:
org.hibernate.PropertyValueException: not-null property references a null or transient value : com.mypackage....
0
votes
1
answer
194
views
Hibernate - How to persist computed column on database side
Could someone help me to identify a solution, which would allow me to compute column's value on insert.
I have tried different combinations with @Formula and @Genarated. Is this even possible ? If so ...
1
vote
1
answer
1k
views
How to map a collection Map<String,List<String>> type using Hibernate
The question was to persist the following class using Hibernate .
Public class Album{
Private int albumid;
Private String aname;
Private Map<String,List<String>> photos;
}
I have Tried ...
1
vote
0
answers
81
views
Possible to retrieve selected children list from database only by using JPA/Hibernate-Annotation?
Guess this might be a difficult one. Well, at least for me. I need some help with JPA/Hibernate-Annotations and I was wondering, if there is a way to solve my problem. Unfortunately, my own skills ...
1
vote
1
answer
530
views
OneToOne mapping JPA - Cascade.All not copying the id column
I tried searching for this specific issue but could not get any help
While creating Employee --> Account should get created.
My entities are --> Employee entity
@Entity
@Table(name = "...
0
votes
1
answer
967
views
Annotation to check set of possible values for string column - Hibernate JPA
How to check only set of possible values for the String column in hibernate.
@Column(name="delivery_type")
private String deliveryType;
I just want to accept only 1 value from these sets of two. ("...
5
votes
1
answer
6k
views
Is there a new @Type annotation that works with spring-data-jpa?
I'm working with SQL Server and Spring Data JPA. I'm trying to get the uniqueidentifier type working, but it seems that it uses uuid_byte as the type instead of uuid_char. I saw other older posts that ...
0
votes
1
answer
350
views
How to set the action on cascade delete to a collection table with Hibernate/JPA
I have a CollectionTable looking like this:
@ElementCollection
@CollectionTable(
name="FOO_FEES",
joinColumns=@JoinColumn(name="FOO_ID",
foreignKey=@ForeignKey(name="...
0
votes
0
answers
568
views
Joining Hibernate Entities with a UK on Part of a Composite Primary Key
I am using Hibernate 4.3 and am trying to model the relationship within the entities of a legacy database that cannot be changed.
I am trying to map a many-to-one relationship between Table B and ...
-1
votes
3
answers
842
views
Can we have @Column and @OneToOne both annotation for one of the variable?
I have 2 tables
Table a - id,b_id,name
Table b - id , name
when I have to make POJO Entity, I wanted to have b_id as a column and as well as foreign key to fetch values from b .
0
votes
0
answers
881
views
@Column, @Length, @Size annotation in hibernate - used simultaneously
I try to understand which annotation for hibernate field have highest precedence. I use @Column, @Length and @Size for the same field and want to know which value will be taken to set column length in ...
0
votes
0
answers
265
views
Hibernate Query Resulting in Missing Expression in Oracle
We use Hibernate as ORM to map our entities to Database .
All our Database query / transactions happens through entity . The Queries for Database (select/insert/update/delete) are generated by ...
0
votes
1
answer
245
views
Conditional @AttributeOverride Hibernate annotation
I have two tables FoodAudit and IngredientAudit that mirror (plus some additional columns) the tables Food and Ingredient as part of a revisions system I am working on. Ideally, both of these tables ...
0
votes
0
answers
118
views
OnetoOne bidirectional mapping not working with spring and hibernate
I have two tables employee and address , when using OnetoOne mapping only in employee entity ,it fetches correspondent address from address table. But when i try to use OnetoOne in address entity to ...
10
votes
3
answers
23k
views
how to do unit test validation annotations in spring
I have some annotation in a class such as
public class ProductModel {
@Pattern(regexp="^(1|[1-9][0-9]*)$", message ="Quantity it should be number and greater than zero")
private String quantity;
...
1
vote
0
answers
2k
views
Hibernate does not populate generated @CreationTimestamp and @UpdateTimestamp on entity with composite ID
I am using JPA and Hibernate 5.
Normally, if an java bean is saved by Hibernate, I expect all the persisted values, including those generated ones, like ID, by database or by code, are populated on ...
0
votes
0
answers
200
views
I have to persist a Map<EntityType, List<EntityType>> with JPA
I'm trying to persist an Entity that has a Map as one of its values. To be more precise. I have the @Entity Request that have a compound primary key with three elements. This primary key is composed ...
2
votes
2
answers
23k
views
Unable to acquire JDBC Connection in spring hibernate annotation based configuration
I have spring java based configuration.
HibernateConfiguration
package com.app.surveyapp.configuration;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
...
2
votes
0
answers
942
views
Join two tables on basis of One common column via Hibernate Annotation and JPA criteria Query not working as expected
I have two tables device_data and device_connection. I want to join these two tables on basis of column customerId. Both the tables have customerId column.
DeviceData
import java.io.Serializable;
...
0
votes
1
answer
956
views
The method addAnnotatedClass(Class<demo>) is undefined for the type Configuration
The method addAnnotatedClass(Class) is undefined for the type Configuration
I am trying to insert data into data base using Hibernate in my Dynamic web project . Annotations are used instead of XML ...
1
vote
0
answers
16
views
Eclipse Unable to create instance of annotation processor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor [duplicate]
I have a project with Hibernate annotations and annotation processing enabled in eclipse.
Once I switch to JAVA 11 Open JDK, the annotation processing is not working.
Below is the full error:
...
1
vote
0
answers
137
views
Hibernate @OneToOne gets a NullPointer Exception
I am reviewing my Java skills and your support to the community is amazing, your tips have helped me a lot.
I am stuck in a Hibernate @OneToOne configuration, it is a very simple design and code but ...
0
votes
1
answer
1k
views
Update column name for existing Entity class using Hibernate Annotation
I have one column in my Entity Class like :
@Column(name = "createdBy", nullable = false)
private String createdBy;
Later i need to update column name.
Is there any way to update the column name ...
3
votes
1
answer
351
views
Unable to fetch list using criteria
public static List<Image> getList(int userId) {
Session session = HibernateUtil.openSession();
Transaction tx = null;
List<Image> results = null;
try {
tx = ...
3
votes
2
answers
2k
views
Array of anotations in kotlin
What would be the equivalent of the following annotation usage in kotlin:
@TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "int-array", ...
1
vote
0
answers
526
views
javax.validation Constraint, adding a violation to a property of a property
Im trying to use a custom javax.validation Constraint annotation in order to set a violation of one of the fields held on the declaring objects field.
For instance I have a car object
@MyConstraint
...
0
votes
1
answer
228
views
Casued Hibernate by (One-toOne) : org.hibernate.AnnotationException: Unknown mappedBy in: referenced property unknown:
I'm tried to create one-to-one relationship in hibernate, When I'm implement this relation then I'm getting org.hibernate.AnnotationException. Please identify the mistake And Suggest me.
Vegetable ...
0
votes
1
answer
206
views
How to migrate Hibernate @Audited informarion from table field?
I need to change my database structure that way: move one field from @Audited entity to another @Audited entity with no loss of audit information. How can I migrate it?
By liquibase migration I ...
0
votes
0
answers
56
views
How to customize the query that is used to fetch the "many" related entities of a one-to-many relationship?
I am developing a Q&A-style web application in which two of the entities are Question and Answer. A Question has-many Answers. In addition, an Answer has-many Answers (which I refer to as child ...
1
vote
2
answers
2k
views
JPA OneToOne UPDATE instead of INSERT
I am new to Spring/JPA and I am trying to use Database relationship @annotations to simplify my code.
I have two entities, a User and Token entity.
When setToken() is called on the User, I want the ...
0
votes
1
answer
708
views
Hibernate self join exception: No row with the given identifier exists
I have a table as following
CREATE TABLE labour_no_pk (
id bigint(20) NOT NULL AUTO_INCREMENT,
name varchar(255) DEFAULT NULL,
labour_id bigint(20) NOT NULL,
contractor_id bigint(20) DEFAULT ...
0
votes
1
answer
365
views
Java Hibernate invalid mapping exception
My code was working just fine with the xml mapping then I changed to annotations and i get this error:
Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML
This is my ...
1
vote
1
answer
59
views
Eagerly loading a persistent object using hibernate annotations
I have three objects: A, B, and C.
A has a one-to-many relationship with B.
B has a one-to-many relationship with C.
The classes are as follow:
public class A {
@OneToMany(fetch = FetchType....
1
vote
1
answer
1k
views
Are SequenceGenerators names globally unique in hibernate 5?
I am upgrading from Hibernate 4.3 to 5.2.13. I have a pattern where many entities inherit properties from an abstract class which is itself annotated. For example:
Entity A:
@AttributeOverride(name =...
1
vote
1
answer
3k
views
maven-compiler-plugin 3.6.0 doesn't compile generated sources from annotations
We just upgraded our JBoss from 6.1.0 to Wildfly 10.1, and made a variety of associated upgrades to modules and artifact versions and so on. In one module this caused our cobertura compiles to fail ...
3
votes
0
answers
2k
views
How to set hibernate @GeneratedValue strategy dynamically in spring boot application?
I have an spring boot applicaion that should be run on mysql in development environment and on sql server on production environment.
so i want to set @GeneratedValue(strategy = GenerationType.IDENTITY)...
5
votes
1
answer
6k
views
How to audit just part of superclass in hibernate?
I want to ask how to audit just a part of a superclass of entity, using hibernate annotations such as @AuditOverride, @Audited or else. Right now, I am using hibernate 5.2.12 version.
The annotations ...
2
votes
0
answers
622
views
org.hibernate.MappingException: broken column mapping for: terminal.id of: com.domain.agent.Agent
I am getting exception while stating of spring boot server. second table(XYZ) which I want to innerjoin has 2 keys(AGENTID,TERMID) and AGENTID is the primary key in both the tables.
@Entity
@Table(...
0
votes
0
answers
771
views
How to write Mapping for Object type in Hibernate by using annotation is it possible to store object type data in Table
I have a entity class that having Object type as variable how to write mapping for the same.
@Entity
@Table(name="demo")
public class Transaction implements Serializable {
@Id
@...
3
votes
2
answers
4k
views
Can an INITIALLY DEFERRED constraint be defined using a Hibernate annotation?
I have a table with a column that has a UNIQUE constraint. I want the constraint checking to be deferred to commit time.
If I create it using Postgres SQL like this (many columns omitted):
CREATE ...
0
votes
1
answer
929
views
I am getting UnsatisfiedDependencyException in my project
I am getting UnsatisfiedDependencyException in project
and i have used all jars related with spring-mvc spring-tx hibernate mysql connector and all by using maven tool
type Exception report
...
0
votes
1
answer
1k
views
Add Case Statement in hibernate
I am creating as API which send the response to Client in JSON format.
What I am doing, I have a table In Mysql DB in that there is a primary key. Client request Data using that Primary Key as a ...