I am using hibernate 3.2.6, and spring 2.5.6
The database Im connecting to is: DB2 for Z OS 390 V8.1
When I run my testcase (below) I save the test file object. Hibernate DOES Save the object to the database, but my test blows out after the save, where it's trying to update the object with the correct id. I think that it's not getting...
Hi all,
I am playing around with the hibernate Criteria API for the first time recently.
I was trying to do the equivalent of this HQL
"select t.userTbl from Task t"
userTbl property is a many-to-one from Task. The Task.userTbl relationship is lazy.
So I came up with this
Criteria criteria = session.createCriteria( Task.class, "t"...
I would like an entity "A" to map only to the primary key over a foriegn key.
class A {
long id;
long bId;
}
class B {
long bId;
...
}
How do i do this ?
...
I know this should be a pretty elementary issue to fix, but 1) I'm relatively new to Hibernate, and 2) the fixes I've found don't (seem to) apply here.
Here is the exception I am getting:
org.hibernate.MappingException: An association from the table POSTS refers to
an unmapped class: com.beans.User at
org.hibernate.cfg.Configuration...
I have a table called group, that I am trying to map using hibernate for DB2 and HSQLDB. Table name group is a reserved word and it must be quoted in HSQLDB. However DB2 does not like quoted table name.
So this mapping works in HSQLDB but not in DB2:
@Entity
@Table(name="`group`")
public class Group {
Mapping results in following err...
I have 2 tables:
orders: id
items: id, orderId, total, flag
I would like to make following query using Hibernate Criteria (DetachedCriteria):
SELECT
o.id,
SUM(i1.total),
SUM(i2.total)
FROM
orders o
LEFT JOIN
(
SELECT
i.orderId ...
I am using Hiberbnate 3.1.3. I have a mapping as below and when I try to insert a record into the TEST_TABLE, I get an Exception: 'Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator'
<class name="com.test.app.to.TestTable" table="TEST_TABLE" schema="TEST">
...
I am using SQL Server 2005 Express.
While I am executed the query I am getting wrong values
select City, City2
from
sample.dbo.NameAddress
where
FirstName like 'rama%'
and LastName like 'suresh%'
Getting same values for the both columns but actually they are different in DB,
When I see entire table ...
I've created a UserType (see below) to handle a situation in our mySQL database where we've been saving null dates as 0000-00-00 00:00:00.
When I try and persist my entity with a null for dispDT (see below) it generates this exception: "javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property refer...
Hi all.
I need to know how can I set Hibernate (...) to achieve the following issue:
I have a bidirectional (composition) one-to-many association (a.bs is a Set object and b.a is a A object). When I load "a" from DB and I update one of its "bs" I need Hiernate intercept A entity when saveOrUpdate A.
Code:
public class A {
Set<B> b...
This should be a simple one I hope.
I have an invoice and that invoice has a list of payments.
Using the Criteria API I am trying to return a list of invoices and their payment total. So, in SQL I want something like this:
SELECT i.*, (SELECT SUM(PMT_AMOUNT) FROM INVOICE_PAYMENTS p WHERE p.INVOICE = i.INVOICE) FROM INVOICES i
I can'...
Hi
I used Spring's HibernateTemplate to save entity, I also add call back method like this
@PrePersist
public void prePersist() {
setCreateDate(new Date());
}
but I found this callback annotation was not called when I called saveOrUpdate() method.
public void persist(Object entity) {
hibernateDaoSupport.getHibernateTemp...
Because of some limitation, client asked that I can't use incremental "id" primary key, only compound primary key is allowed. And I can't use JPA annotation to have entity callback. Thus how can I know an entity is going to be inserted or updated ?
thanks a lot.
...
Dear Sirs,
The preface: I'm struggeling with LazyInitializationException in my Unit Tests, and I have a really hard time getting my head around it, as you can see from my questions
Database Sessions in Spring, TestNG and Spring 3 and LazyInitializationException while unit-testing Hibernate entity classes for use in Spring, using TestNG...
SQLQuery query = session.createSQLQuery("select {o.id} from order o " +
"LEFT JOIN bookings b ON b.id = o.bookingId " +
);
List pusList = query.addEntity(Order.class)
.list();
and in order class I have:
@OneToOne(cascade = CascadeType.ALL, mappedBy = "order", fetch = FetchType.LAZY)
private Trip trip;
but during exec...
Hibernate has the option to auto-detetect the hibernate.dialect. How can I retrieve that auto-detected value? I was unable to find any information on this.
...
Hello,
I am using spring and hibernate for configuration with mysql db.
My we.xml file has following code :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun....
I have following Hibernate 3 mapping for User class:
<class name="org.test.User" table="users">
... some other mapping...
<map name="metadata" table="user_metadata">
<cache usage="transactional"/>
<key column="user_id" not-null="true" foreign-key="FK_USERMETADATA_USER_ID"/>
<map-key type="string" column="da...
How exactly are these 4 components related, any good explanations someone can offer or links or whatever useful.
...
Hi,
I am getting the following exception
[Microsoft][SQLServer 2000 Driver for JDBC]Connection reset by peer: socket write error
Its happening on the application server when the web app tries to access a database located on another machine over a network. Now I have read some posts on this, and found many different answers. One wa...