As per docs org.hibernate.type.YesNoType is supposed to generate char(1) during schema2ddl generation. But the following definition generates char(255) by default for databases like H2, MySQL
@Column(name = "enabled")
@Type(type = "org.hibernate.type.YesNoType")
private Boolean enabled = Boolean.FALSE;
Adding a hardcoded value for col...
The following query is supposed to return about 800 objects. The problem is that hibernate actually executes 800 queries to get them all. It appears to execute one query to get the ids and then executes one query for every object to get the specific data about the object. It takes over 60 seconds for this query to return.
List<AUser> re...
I am trying to write to an Oracle clob field a value over 4000 characters. This seams to be a common issue but non of the solutions seem to work. So I pray for help from here.
Down and dirty info:
Using Oracle 9.2.0.8.0
Hibernate3 implementing pojo's with annotations
Tomcat 6.0.16
Oracle 10.2.x drivers
C3P0 connction pool provider
In...
Hibernate is not deleting orphans when I set the collection to null, although orphans are deleted when the collection is cleared. I have the following associations.
D - entity, contains a single embedded E
E - embedded object, contains one to many relationship with F (cascade type all,DELETE_ORPHAN)
F - entity, contains a collection of...
I'm working on creating a Hibernate query engine that can create dynamic queries. Thus far I've been using the Criterion API to generate the queries. I'm having a hard time writing the engine in an OO fashion. I want to be able to create a new class for each association and have it pass back a fragment of the SQL call.
For example:
...
This is how my entity look like
@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "TestPojoOnly")
@NamedQueries({@NamedQuery(name = "TestPojoOnly.findAll", query = "SELECT h FROM TestPojoOnly h"), @NamedQuery(name = "TestPojoOnly.findById", query = "SELECT h FROM TestPojoOnly h WHERE h.id = :id"), @Na...
I loaded same entity record on 2 separate browser window then press submit (hibernate template.merge), version number incremented for both browser window, but never caught any problem with optimistic lock.. so how to test this?
my save() look like this
hibernatetemplate().merge(..);
setJPAObject(null); //reset after save
...
Hi
Our project must be able to run both in Oracle and SQL Server. The problem is we have a number of HQL + native queries with non-standard operators (i.e. bitand and || ) and functions ( i.e. SUBSTR ) that work fine in Oracle but not in SQL Server.
I wonder if Hibernate is capable of translating them dynamically. I suppose that with ...
I am hitting an issue with my Hibernate backed Jpa queries returning data that is not up to date. I assume it is an issue with pulling data from the cache instead of the database itself.
For example, I will change and persist an object on one page and then go back to the previous page, which lists rows of the database, and it will show ...
I am sure that someone familiar with HQL (I am myself a newbie) can easily answer this question.
In my Grails application, I have the following domain class.
class Book {
org.joda.time.DateTime releaseDate //I use the PersistentDateTime for persisting via Hibernate (that use a DATETIME type for MySQL DB)
}
In my HQL query, I want t...
Hi,
Assume I have the following Groovy class (or the equivalent in Java)
class User {
Long id
String name
}
I would like to write a Hibernate query (either HQL or Criteria) which returns all the users that have at least one other user with the same name.
Update
The following query has been suggested
select min(user.id), u...
If you had two databases, that had two tables between them that would normally implement a one to one (or many to many) constraint but cannot since they are separate databases, how would you validate this relationship in an application or test?
Is there a simple way to do this? For example, a tool or technique that can, given a constrai...
We have a SQL Server database table that consists of user id, some numeric value, e.g. balance, and a version column.
We have multiple threads updating this table's value column in parallel, each in its own transaction and session (we're using a session-per-thread model). Since we want all logical transaction to occur, each thread does ...
Hi,
In my DAO implementation I'm doing Stripersist.getEntityManager().persist(client);, this doesn't seem to return any errors, but I can't find the data that it persists.
My client object looks like this :
@Entity
public class Client implements Serializable
{
@Id
@GeneratedValue
private Integer id;
@Column
priva...
Firstly I have three entities.
Users, Roles, Items
A user can have multiple Roles.
An item gets assigned to one or more roles.
Therefore a user will have access to a distinct set of items.
Now there is a few ways I can see this working.
There is a Collection on Users which has Roles via a many-to-many assoc. Then each Role in thi...
I am trying to model such situation - there is a cash transfer (I mean a car that carries money), that has required amounts of each currency, and also an actual amount for each currency. And it seems to me pointless to create two separate classes, one for required amount and another for actual amount. So the implementation would look lik...
Hello there,
I too have the same situation and i had configured the OpenSessionInViewFilter like this in my web.xml.
<!-- Hibernates session management for request -->
<filter>
<filter-name>hibReqSessionFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
...
Hi there,
I'm migrating some of my hql-statements to Criterias now I'm figuring one problem:
The entity property is type Integer but I need a like with wildcards search, so in hql I do
session.createQuery("from P1 where id like :id").setString("id", "%"+s+"%")
No problem at all, Hibernate casts String to Integer.
If I try this in Cr...
I'm running an application with the following components:
Oracle 9i
WAS 6.1.0.23 with WS and EJB3 features pack
JPA with Hibernate 3.3.2.GA as provider (with Hibernate-EntityManager 3.4.0)
Spring transaction manager for WAS : UowTransactionManager (spring 2.5.6)
Spring webflow with flow-managed persistence (2.0.8), i.e. the entity mana...
I'm trying to integrate Spring Security with Hibernate. I'm new to both technologies so I'm almost certainly taking too many steps at once here, but I'm at the point where I want to authenticate a user from the database. I think this is certainly more a Hibernate problem that a Spring Security one but I mention it to give some context. ...