hibnerate update data, remove the data and the actual data in the database consistent.

Category: Java EE
 
tggdcz
2011-01-23 07:00:29

Sponsored Links
This is not a secondary cache reason I did not configure the secondary cache, the default is not to use it or not use the secondary cache mechanism.

PO following is my configuration:

<? xml version = "1.0" encoding = "UTF-8"?>

<! DOCTYPE hibernate-mapping PUBLIC
"- / / Hibernate / Hibernate Mapping DTD 3.0 / / EN"
"

<hibernate-mapping
>
<class
name = "com.hzsos.common.pojo.CustomList"
; table = "hzsos_customlist"
>

<id
name = "id"
column = "id"
type = "int"
unsaved-value = "null"
>
<generator class="native">
<! -
; To add non XDoclet generator parameters, create a file named ;
hibernate-generator-params-CustomList.xml ;
containing the additional parameters and ; place it in your merge dir.
-> ;
</generator>
</id>

<property
name = "name"
type = "string"
update = "true"
insert = "true"
column = "name"
length = "20"
/>

<property
name = "abbr"
type = "string"
update = "true"
insert = "true"
column = "abbr"
length = "10"
/>

<set
name = "items"
table = "hzsos_customlistitem"
lazy = "true"
inverse = "true"
cascade = "all"
sort = "unsorted"
>

<key
column = "customListId"
>
; </key>

<one-to- many
class = "com.hzsos.common . pojo.CustomListItem "
/>

</set>

<! -
To add non XDoclet property mappings, create a file named
; hibernate-properties-CustomList.xml
containing the additional properties and place it in your merge dir.
->

</class>

</ hibernate-mapping>

Sponsored Links

jessie214078
2011-01-23 07:06:12
is not your cached pages up? Do not try cached pages
llllyyyyaaaajjjj
2011-01-23 07:11:02
say under what action you performed, what inconsistency?
is not updated after the data did not commit?
how the data will be removed and database data inconsistencies, not that out of it in the database?
huaxang013
2011-01-23 07:29:55

public void updateCustomList (CustomList customList) {

Session session = ; customListDAO.getSession ();
Transaction trans = null;
try {
trans = session.beginTransaction ();
customListDAO.merge (customList );
trans.commit ();

} catch (RuntimeException re) {
trans.rollback ();
} finally {
session . close ();
}
}

qunslh
2011-01-23 07:48:51
package com.hzsos.common.dao;

import java.util.List;

import org.hibernate.Query;

import com.hzsos.common.pojo.CustomList;
import com. jfsuite.util.db.BaseHibernateDAO;

public class CustomListDAO extends BaseHibernateDAO {

private static final String LOAD_ALL = " from CustomList ";

public List findAll () {
Query queryObject = getSession (). createQuery (LOAD_ALL);
return queryObject . list ();
}

public CustomList findById (Integer id) {
return (CustomList) getSession (). get (CustomList. class, id);

}

public void save (CustomList customList) {
getSession (). saveOrUpdate (customList);
}

public void delete (CustomList customList) {
getSession (). delete (customList);
}

public void delete (Integer id) {
getSession (). delete (findById (id));
}

}
zhou987654321
2011-01-23 08:02:46


execution updateCustomList (CustomList customList), the database is updated records in the table, and I take out on the page of data or old data.
aier123
2011-01-23 08:20:48
see if the page cache
zhengye0186
2011-01-23 08:36:20

is not your cached pages up? Do not try cached pages

>>> how to set up?
william_lu
2011-01-23 08:41:56
Does anyone help me
lxm222
2011-01-23 08:49:43
some body helps
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.