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.

hibernate
Filter by
Sorted by
Tagged with
0 votes
1 answer
571 views

Can we use multiple sessions in a JUnit testcase?

I have been trying to write a Junit testcase for the following class. I am able to run one testcase successfully. I am using session to get the data from the database through server. I am trying to ...
2 votes
1 answer
1k views

org.hibernate.cache.CacheException: Unsupported access type [read-write]

I am trying to enable second level caching using EhCache but facing problem in my server startup. When I specify @Cache(usage=CacheConcurrencyStrategy.READ_WRITE) for my DTO class, I am getting below ...
0 votes
0 answers
848 views

Why aren't properties injected by Spring into LocalContainerEntityManagerFactoryBean?

I have the following config class: @Configuration @PropertySource(value = "classpath:my.properties") @EnableJpaRepositories("com.my.data.repository") @EnableTransactionManagement public class ...
1 vote
1 answer
175 views

JBoss Fuse Hibernate integration

I try to develop simple Hibernate integration application in FUSE but could not find good reference document which I can follow. I have go through the official documentation regarding Hibernate ...
1 vote
1 answer
156 views

Hibernate Tools not recognizing many to many relation

When I try to auto-generate my entity classes, hibernate tools generates the many to many class and doesn't make the generation many to many. These are my tables: CREATE TABLE `role`( `id` int(13)...
0 votes
0 answers
237 views

Postgresql export insert statements with a column annotated JPA @Lob

I am facing an issue while exporting insert statements from postgresql database. Let me give you some information ; Lets say I have a Foo class and a String field which is annotated with JPA @Lob ...
15 votes
4 answers
24k views

What does Hibernate.initialize do?

What does Hibernate.initialize do? Usually referred documentation talk only about Hibernate.initialize(entity.lazyCollection) Is there any sense in Hibernate.initialize(entity)
0 votes
0 answers
2k views

How to get List of objects, which contain List using hql query in java?

I have faced to problem. I have two tables t1 and t2. And they connected with foreign key(more exactly t1 has field id and t2 table has id_t1_fkey field). One record in t1 can have one or more ...
0 votes
1 answer
694 views

Hibernate many-to-many syntax error in sql statement

I have an issue with an hibernate many-to-many relation: when I want to read data from database SQL syntax error occurs. I found this in every tutorial so I guess it should work. My classes in many-...
2 votes
1 answer
6k views

Hibernate auto increment ID and a composite key

I am using hibernate version 5.2.4 and postgresql v 9.4 and trying a create an annotated class which will help me build a table as below: ID | client_name | company_name | email ---+----------...
0 votes
1 answer
785 views

Can I use generic type with @Entity?

I'm defining generic @MappedSuperclass for future usage. In my experience all categories has same code. Then I think I can create generic Category and multiple sub classes. But hibernate can't fetch ...
1 vote
1 answer
596 views

Why to choose Spring Data JPA Over Hibernate?

Why to choose Spring Data JPA Over Hibernate ? Assuming I am developing Spring MVC + Spring REST + Spring Security application using Oracle.
1 vote
1 answer
2k views

Hibernate - different values of two fields mapped the same column

I have two fields mapped the same column: @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "database_id", nullable = false, insertable = true, updatable = true) private Database database; @...
0 votes
1 answer
169 views

Interbase DB: Unable to create requested service: Hibernate Session

I'm having difficulty getting a Hibernate Session to work when connecting to an Interbase DB. I can connect to the database through JDBC but I'm not sure why my Session fails to instantiate when ...
3 votes
2 answers
4k views

Hibernate 4.2 OneToMany EntityNotFoundException

I'm running into an exception that seems widespread on SO but cannot find a solution. I have two classes. Document and Keyword. Each document contains many keywords. Possibly to complicate things, ...
4 votes
3 answers
2k views

How to Ignore Certain Fields in unit tests, Hibernate

I have the following field in my entity model. @Column(name="key") @ColumnTransformer( read="AES_DECRYPT(key, SHA1('passcode'))", write="AES_ENCRYPT(?, SHA1('passcode'))") private ...
3 votes
3 answers
2k views

Hibernate search on prefixes

Right now, I have successfully configured a basic Hibernate Search index to be able to search for full words on various fields of my JPA entity: @Entity @Indexed class Talk { @Field String title ...
2 votes
2 answers
5k views

Failed to load ApplicationContext during unit test

I am quite new to java EE spring boot and thought I would start a small project to get to grips with things, I am currently getting an error as stated above failed to load ApplicationContext and I am ...
0 votes
1 answer
2k views

Why is jTDS failing to convert SQL Server datetime to java.sql.Timestamp?

Here's my mapping. @Column(name = "someDateTime") // which is `datetime` in SQL Server table public java.sql.Timestamp getSomeDateTime() { return someDateTime; } URL is spring.datasource.url=...
2 votes
1 answer
3k views

How to verify that data source is valid and configured properly?

In application start up , I am loading data source as shown below code - @Bean(name = "dataSource") public DataSource getDataSource() { ComboPooledDataSource dataSource = new ...
0 votes
1 answer
8k views

Unable to release JDBC Connection

I'm new to JPA & Hibernate, I'm performing reset password action. In that case, the entity object (User) is getting updated after that I'm trying to log-in but unfortunately, the server is hung ...
0 votes
0 answers
130 views

jpa how to fetch namedEntityGraph on detached entity?

What is the best way to do additional work on detached entities? Some context... I am currently fetching the user in a Filter for my REST services. In some cases, I need work with some lazy ...
2 votes
1 answer
202 views

HQL does not like plus character

HQL parse DATEADD(m,-1,GETDATE()) as DATEADD(m,-1,GETDATE()) HQL parse DATEADD(d,-1,GETDATE()) as DATEADD(d,-1,GETDATE()) HQL parse DATEADD(d,+1,GETDATE()) as DATEADD(d) HQL parse DATEADD(h,+23,...
3 votes
1 answer
2k views

Hibernate Envers SQL auditing

I was wondering if anyone had succeeded in auditing a native query (SQL) with Hibernate Envers? I know this is probably just wrong, but it would spare me a lot of refactoring time. Cheers Nick
0 votes
0 answers
51 views

Making one entity to have two association with other same entity

I have two entity "user" and "vehicle". In this user can be a owner or driver of vehicle If user is owner he will have one to many relation with vehicle that is working fine But if user is driver ...
0 votes
1 answer
206 views

How are DriverManagerDataSource connections created?

I have been reading about DriverManagerDataSource in its documentation. And I ran into this sentence: NOTE: This class is not an actual connection pool; it does not actually pool Connections. It just ...
1 vote
1 answer
3k views

HQL - conditional WHERE clause based on column

I'm rather new to HQL and I'm trying to add a WHERE clause to my hql query in order to only apply a filter in case one of the columns has a certain value. I've read about the CASE WHEN statement and I'...
1 vote
1 answer
2k views

Classloader settings do not apply on Websphere 8

I have IBM Websphere 8.5.5.10. and hibernate-jpa-2.0-api-1.0.0.Final.jar is a default jar. However, I want to use a newer version -> hibernate-jpa-2.1-api-1.0.0.Final.jar. I set "Classes loaded with ...
0 votes
1 answer
71 views

Find wether hibernate entity column(field member) is nullable at runtime

I have a problem where I would like to find that a field of a hibernate entity(by entityClass) is representing nullable column or not. However I want to get it using reliable hibernate meta not like ...
6 votes
2 answers
7k views

understanding JTA Spring and Bitronix

I am trying to understand what is the difference between JTA, Spring and Bitronix? What should I use for transactions in Hibernate persistence?
0 votes
2 answers
742 views

Error in Spring with JPA and Hibernate

I am following this pluralsight tutorial for understanding Spring with JPA and Hibernate.I am stuck for few days on below error. SEVERE [RMI TCP Connection(3)-127.0.0.1] org.springframework.web....
2 votes
1 answer
879 views

Hibernate can't load class when packaged, but can in IDE

When I run my program in Intellij, it works fine. Maven will package it perfectly happily, and it will launch fine, but as soon as I try to retrieve anything from the database with hibernate, I get ...
1 vote
2 answers
2k views

Hibernate doesn't create an h2db table

I'm trying to make a spring security login through h2 database and i have two entities: Users and UserRoles. They connected via one to many annotation. After i run my app, UserRoles table and ...
0 votes
1 answer
2k views

How to use subgraph in spring-data(with hibernate)?

I'm using spring boot 1.2.5 and Hibernate 4.3.10 via spring data, and I wrote the code below. I want to use subgraph so that I can retrieve data when I get the entity graph named "content.search". ...
0 votes
0 answers
44 views

Hibarnate does not write to db sometimes

I have a threadpool that produces listenableFutures from guava. Upon failure of the task I write in the DB using two methods. First method writes an entry with various information and second updates ...
0 votes
1 answer
2k views

JDBC Begin Transaction Failed Hibernate (Broken pipe)

I use spring in a webapp, after I make an operation that takes a relatively large amount of time upon a request from front-end, and then try to access a hibernate entity I have an error, this is the ...
0 votes
0 answers
550 views

Hibernate SQL Error Column not found

The FIELD_5 is primary key in TABLE_1 and not a foreign in TABLE_2. Its showing FIELD_5 column not found. Have used Hibernate XML for mapping. FIELD_5 is mapped into XML Caused by: java.sql....
2 votes
1 answer
1k views

Is it possible to add custom parameters to @SQLDelete override in Hibernate?

Is it possible to add custom parameters to @SQLDelete override in Hibernate? I don't want to have to edit Hibernate source code. In the example below I am trying to include a lastUpdatedBy column in ...
0 votes
1 answer
276 views

Hibernate : Generate a number for an integer column (not primary key)

Is it possible to generate a number for a column that is not a primary key? There is the @GeneratedValue for generating ids, but I'm not certain if I can use it for usual columns as well.
2 votes
0 answers
2k views

PersistentObjectException: Uninitialized proxy passed to persist

I am working with Spring Data JPA and an MySQL database for a records management system. Below are two entities that I have modeled and I am trying to persist a Policy record to the database: Policy ...
0 votes
0 answers
92 views

Hibernate don't persist in database

I'm new in using spring mvc and this is my first application , so I Followed a tutorial and I have a problem . When I run the server(Tomcat ) , hibernate don't persist or add table in mydatabase , ...
2 votes
2 answers
2k views

Convert float/int to Calendar in jpa hibernate SQL Server

I'm developing a Java project with JPA / Hibernate and SQL Server DB. I got an existent db where date fields are stored as int and datetime as float. Does anyone know how can I implement a ...
1 vote
0 answers
206 views

how to delete an object while SaveOrUpdate in hibernate

I have a collection of B's nested in an object of A ,and also i have 3 rows of B in database.First of all i fetch all 3 B in my grid view, and i delete 2 B there now i want to execute save Or Update ...
2 votes
1 answer
636 views

How to add a default WHERE condition to NHibernate queries for a certain type

I'd like all queries that query a certain type, to include a where statement by default. More exactly, I have an interface IIsTenantSpecific, with a property TenantId - so the entities belong to a ...
0 votes
1 answer
521 views

Perform an action in Spring when database value is changed by another backend service [closed]

I have 2 projects. The first project is using spring boot hibernate and angular.js. The other is a backend service, which receives data and inserts it into a table. I want to perform an action in ...
3 votes
0 answers
285 views

Hibernate statistics print HQL : null

I am new to using hibernate. I turned the statistics on, and together with normal HQL queries I get many such stats - [INFO] Statistics HQL: null, time: 1724ms, rows: blah Can someone help me in ...
0 votes
0 answers
212 views

Hibernate statistics logging "null" query

So I need to benchmark the queries generated by Hibernate and their execution time for a huge spring web application. I am using the statistics package provided by Hibernate to do it. The queries are ...
0 votes
1 answer
79 views

How to get Joda-Time LocalTime same with that stored in SQL Server using Hibernate

I stored "06:00:00" in a SQL Server database as a time(0) type. Our time zone is "Australia/Sydney". How can I convert the time to "06:00" in Java code using Joda-Time? I have tried the following: @...
0 votes
0 answers
63 views

Only one entity generated in database [jee]

i am new in jee i create two entities with different namedquery. when i run my application on wildfly 10, only one entity generated in the data base despite when i check my console i find my two ...
4 votes
1 answer
2k views

Hibernate query on superclass property

First of all, please forgive my ignorance in both Java and Hibernate, I'm studying different ORM solutions and am not a Java programmer. 1) Is it possible to map the following class hierarchy to a ...

1
930 931
932
933 934
1903