[Hibernate-JIRA] Created: (HHH-2296) Reduce count of entites which are evicted from 2nd level cache on update
by Veklov Alexey (JIRA)
Reduce count of entites which are evicted from 2nd level cache on update
------------------------------------------------------------------------
Key: HHH-2296
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2296
Project: Hibernate3
Type: Improvement
Components: core
Environment: Hibernate 3.2 cr2/cr3, JBoss TreeCache/EhCache, Oracle
Reporter: Veklov Alexey
Priority: Trivial
There is code snippet from EntityUpdateAction.execute:
if ( persister.hasCache() ) {
if ( persister.isCacheInvalidationRequired() || entry.getStatus()!=Status.MANAGED ) {
persister.getCache().evict(ck);
}
else {
AbstractEntityPersister.isCacheInvalidationRequired has the following comment:
/**
* We can't immediately add to the cache if we have formulas
* which must be evaluated, or if we have the possibility of
* two concurrent updates to the same item being merged on
* the database. This can happen if (a) the item is not
* versioned and either (b) we have dynamic update enabled
* or (c) we have multiple tables holding the state of the
* item.
*/
public boolean isCacheInvalidationRequired() {
return hasFormulaProperties() ||
( !isVersioned() && ( entityMetamodel.isDynamicUpdate() || getTableSpan() > 1 ) );
}
This logic does not take into account that if we have obtained pessimistic lock on entity through
select ... from <join of all tables holding the state> for update
which is fired by Session.refresh(..., LockMode.UPGRADE)
concurrent updates are impossible.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (EJB-232) Better documentation for <jar-file> and scanning outside of PU root
by Christian Bauer (JIRA)
Better documentation for <jar-file> and scanning outside of PU root
-------------------------------------------------------------------
Key: EJB-232
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-232
Project: Hibernate Entity Manager
Type: Improvement
Components: Documentation
Reporter: Christian Bauer
Priority: Minor
> > I'm trying to solve a problem that people will face as soon as they
> > do unit testing. Given the following directories with classes:
> >
> > - build/classes/MyModel.class @Entity
> > - build/testclasses/META-INF/persistence.xml
> >
> > This doesn't work because the PU root is build/testclasses, and
> > there are no entities there. I've tried to use <jar-file>file://
> > build/classes</jar-file> to point the scanner to that directory,
> > but it doesn't work either. Apparently it has to be a JAR file.
> >
> > Maybe we should introduce a syntax or fallback for <jar-file> to
> > scan a directory. I see no other way how I could split my entity
> > build path from the test configuration build path. It's almost
> > impossible to find a project layout in an IDE where you could get
> > both together and not run into all kinds of issues.
>
> Oh, it works. I had a slash too many in my URL. Maybe we should add
> this to the documentation:
>
> <jar-file>file:/home/turin/work/local/lab8/build/classes</jar-file>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (EJB-243) Error in Documentation: persistence.xml for typical Java SE Environment
by Michael Plöd (JIRA)
Error in Documentation: persistence.xml for typical Java SE Environment
-----------------------------------------------------------------------
Key: EJB-243
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-243
Project: Hibernate Entity Manager
Type: Improvement
Components: Documentation
Versions: 3.2.0.ga
Reporter: Michael Plöd
Hi,
I just found out that there is a small bug in the example persistence.xml file for a Typical Java SE environment in Chapter 2.2.2 Bootstrapping:
The xml file is as follows:
<persistence>
<persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
<class>org.hibernate.ejb.test.Cat</class>
<class>org.hibernate.ejb.test.Distributor</class>
<class>org.hibernate.ejb.test.Item</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:."/>
<property name="hibernate.max_fetch_depth" value="3"/>
<!-- cache configuration -->
<property name="hibernate.ejb.classcache.org.hibernate.ejb.test.Item" value="read-write"/>
<property name="hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors" value="read-write, RegionName"/>
<!-- alternatively to <class> and <property> declarations, you can use a regular hibernate.cfg.xml file -->
<!-- property name="hibernate.ejb.cfgfile" value="/org/hibernate/ejb/test/hibernate.cfg.xml"/ -->
</properties>
<persistence-unit>
</persistence>
The error is that the <persistence-unit> is not being closed by </persistence-unit> (look two lines up from here) ...
The documentation says:
...
<persistence-unit>
....
<persistence-unit> <---- this must me </persistence-unit>
</persistence>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (HHH-2290) Using a composite-element in a set creates invalid SQL on Oracle if composite-element has a CLOB field
by Frank Durden (JIRA)
Using a composite-element in a set creates invalid SQL on Oracle if composite-element has a CLOB field
------------------------------------------------------------------------------------------------------
Key: HHH-2290
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2290
Project: Hibernate3
Type: Bug
Versions: 3.2.1
Environment: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.7.0
Reporter: Frank Durden
Attachments: test-case.jar
Hi,
With a mapping like the one below I get an "ORA-00932: inconsistent datatypes: expected - got CLOB" if I remove or modify a ChildElement: When Hibernate tries to remove the ChildElement it generates SQL like "delete from TEST_CHILDREN where PARENT_ID=? and NAME=? and VALUE=?". It is not possible in Oracle to use the equal sign with CLOB fields. Test case attached.
A workaround is to use a stored procedure to delete the ChildElement using a "<sql-update callable="true">", but this works only as long as the CLOB field is <32k. With values bigger than 32k you get an "ORA-01460: unimplemented or unreasonable conversion requested", at least with an OCI driver. Anyway, it is quite inefficient to pass huge CLOB fields as arguments on delete operations.
The ultimate solution in my mind would be to have a property tag specifying that the property should not be used in delete operations.
<hibernate-mapping>
<class name="com.test.Parent" table="TEST_PARENT">
<id name="identifier" type="long" unsaved-value="0" column="ID" >
<generator class="sequence">
<param name="sequence">test_seq</param>
</generator>
</id>
<version name="version" type="long" unsaved-value="negative" column="VERSION"/>
<property name="name" column="NAME" type="string"/>
<set name="children" lazy="true" table="TEST_CHILDREN" cascade="all,delete-orphan">
<key column="PARENT_ID" not-null="true"/>
<composite-element class="com.test.ChildElement">
<property name="name" column="NAME" type="string"/>
<property name="value" column="VALUE" type="text"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years
[Hibernate-JIRA] Created: (HHH-2221) Bulk-update of joined-subclass doesn't work with
by Donnchadh O Donnabhain (JIRA)
Bulk-update of joined-subclass doesn't work with
-------------------------------------------------
Key: HHH-2221
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2221
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: INFO: Hibernate 3.2.0
INFO: RDBMS: MySQL, version: 5.0.22
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.4 ( $Date: 2006-10-19 17:47:48 +0200 (Thu, 19 Oct 2006) $, $Revision: 5908 $ )
Reporter: Donnchadh O Donnabhain
Attachments: JoinedSubclassTest.java
I've created the following test (in JoinedSubclassTest) which reporduced the problem:
public void testBulkUpdateJoinedSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();
Employee mark = new Employee();
mark.setName("Mark");
mark.setTitle("internal sales");
mark.setSex('M');
mark.setAddress("buckhead");
mark.setZip("30305");
mark.setCountry("USA");
s.save(mark);
String hql = "update Employee employee set employee.sex=:newSex where employee.id in (:ids)";
Query query = s.createQuery(hql);
query.setCharacter("newSex", 'F');
List ids = new ArrayList();
ids.add(Long.valueOf(mark.getId()));
query.setParameterList("ids", ids);
query.executeUpdate();
s.delete(mark);
t.commit();
s.close();
}
and run it with the following properties:
-Dhibernate.dialect=org.hibernate.dialect.MySQLDialect
-Dhibernate.connection.driver_class=com.mysql.jdbc.Driver
-Dhibernate.connection.url=jdbc:mysql://127.0.0.1/hibernateTest
-Dhibernate.connection.username=username
-Dhibernate.connection.password=password
This produces the following error:
org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:127)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:396)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:259)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1141)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
at org.hibernate.test.joinedsubclass.JoinedSubclassTest.testBulkUpdateJoinedSubclass(JoinedSubclassTest.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:589)
at junit.framework.TestCase.runTest(TestCase.java:164)
at org.hibernate.test.TestCase.runTest(TestCase.java:247)
at junit.framework.TestCase.runBare(TestCase.java:130)
at org.hibernate.test.TestCase.runBare(TestCase.java:313)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'hibernateTest.HT_JEmployee' doesn't exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1404)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1303)
at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:118)
... 26 more
This works fine in hibernate 3.1.3.
The problem seems to be in AbstractStatementExecutor. It seems to assume that if a DDL statement, in general, results in a commit that this will also happen for a temporary table. In the case of MySQL, at least, this is not the case. The code in AbstractStatementExecutor goes and creates the temporary table in a new connection, which, in the case of MySQL, will
not be visible in the current transaction.
http://fisheye.jboss.com/browse/Hibernate/branches/Branch_3_2/Hibernate3/...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years