95,147 questions
2
votes
3
answers
328
views
Can I make Hibernate transparently avoid string duplication in the database?
I have a Java program that uses Hibernate and MySQL to store a lot of tracing data about the use of the Eclipse IDE. This data contains a lot of strings such as method names, directories, perspective ...
3
votes
2
answers
2k
views
Workaround for Spring/Hibernate due to non-standard behaviour of UNIQUE constraint in MS SQL
There is a UNIQUE database constraint on an index which doesn't allow more than one record having identical columns.
There is a piece of code, managed by Hibernate (v2.1.8), doing two DAO
...
2
votes
6
answers
1k
views
Why does Hibernate seem to be designed for short lived sessions?
I know this is a subjective question, but why does Hibernate seem to be designed for short lived sessions? Generally in my apps I create DAOs to abstract my data layer, but since I can't predict how ...
7
votes
6
answers
23k
views
When to use Hibernate/JPA/Toplink?
Right now I'm making an extremely simple website- about 5 pages. Question is if it's overkill and worth the time to integrate some sort of database mapping solution or if it would be better to just ...
8
votes
5
answers
14k
views
Multiple Session Factories under Spring/Hibernate
I have been given a requirement where I need to support multiple databases in the same instance, to support multi-tenancy. Each DB has an identical schema. The user logs into a specific database by ...
6
votes
5
answers
3k
views
How to initialize Hibernate entities fetched by a remote method call?
When calling a remote service (e.g. over RMI) to load a list of entities from a database using Hibernate, how do you manage it to initialize all the fields and references the client needs?
Example: ...
4
votes
2
answers
5k
views
How do I get the value of the jdbc.batch_size property at runtime for a Web application using Spring MVC and Hibernate?
According to what I have found so far, I can use the following code:
LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean)super.getApplicationContext().getBean("&sessionFactory");
...
5
votes
2
answers
6k
views
Compare time part of datetime field in Hibernate
I've got an application that uses a hibernate(annotations)/mysql combination for ORM. In that application, I got an entity with a Date field. I'm looking for a way to select on that date within a time ...
2
votes
4
answers
2k
views
What is the best way to present data from a very large resultset?
I'm writing a report view of an audit trail, and I need to display this in a .jsp. What's the "best" way to get the data from the database to the screen?
We're using Spring for dependency injection, ...
13
votes
1
answer
9k
views
Bypass GeneratedValue in Hibernate
Is it possible to bypass @GeneratedValue for an ID in Hibernate, we have a case where, most of the time we want the ID to be set using GeneratedValue, but in certain cases would like to set the ID ...
12
votes
6
answers
10k
views
hibernate insert batch with partitioned postgresql
is there a solution for batch insert via hibernate in partitioned postgresql table? currently i'm getting an error like this...
ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch:
...
2
votes
8
answers
711
views
Is it worth the effort to move from a hand crafted hibernate mapping file to annotaions?
I've got a webapp whose original code base was developed with a hand crafted hibernate mapping file. Since then, I've become fairly proficient at 'coding' my hbm.xml file. But all the cool kids are ...
1
vote
3
answers
2k
views
What is the best way to load a Hibernate object graph before using it in a UI?
The situation is this:
You have a Hibernate context with an
object graph that has some lazy
loading defined.
You want to use
the Hibernate objects in your UI as
is without having to copy the data
...
15
votes
3
answers
10k
views
Is it possible to use analytic functions in Hibernate?
Is there a way to use sql-server like analytic functions in Hibernate?
Something like
select foo from Foo foo where f.x = max(f.x) over (partition by f.y)
32
votes
8
answers
30k
views
Hibernate mapping a composite key with null values
With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values?
This is to deal with a legacy table that has a unique key which can have null ...
1
vote
5
answers
6k
views
Lazy loading property and session.get problem
In Hibernate we have two classes with the following classes with JPA mapping:
package com.example.hibernate
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax....
37
votes
7
answers
74k
views
How to use hibernate criteria to return only one element of an object instead the entire object?
I'm trying to get only the list of id of object bob for example instead of the list of bob. It's ok with a HQL request, but I would know if it's possible using criteria ?
An example :
final ...
79
votes
8
answers
113k
views
How do you "OR" criteria together when using a criteria query with hibernate?
I'm trying to do a basic "OR" on three fields using a hibernate criteria query.
Example
class Whatever{
string name;
string address;
string phoneNumber;
}
I'd like to build a criteria query where ...
9
votes
2
answers
11k
views
Enabling Hibernate second-level cache with JPA on JBoss 4.2
What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA.
From the ...
1
vote
2
answers
1k
views
Hibernate crops clob values oddly
I have a one to many relationship between two tables. The many table contains a clob column. The clob column looks like this in hibernate:
@CollectionOfElements(fetch = EAGER)
@JoinTable(name = ...
0
votes
2
answers
2k
views
Querying collections of value type in the Criteria API in Hibernate
In my database, I have an entity table (let's call it Entity). Each entity can have a number of entity types, and the set of entity types is static. Therefore, there is a connecting table that ...
13
votes
6
answers
31k
views
Why @OneToMany does not work with inheritance in Hibernate
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Problem {
@ManyToOne
private Person person;
}
@Entity
@DiscriminatorValue("UP")
public class UglyProblem extends ...
8
votes
3
answers
8k
views
Using Hibernate to work with Text Files
I am using Hibernate in a Java application to access my Database and it works pretty well with MS-SQL and MySQL. But some of the data I have to show on some forms has to come from Text files, and by ...
2
votes
2
answers
3k
views
Hibernate saveOrUpdate with another object in the session
Is there any way to save an object using Hibernate if there is already an object using that identifier loaded into the session?
Doing session.contains(obj) seems to only return true if the session ...