[Hibernate-JIRA] Commented: (HB-771) NullPointerException from oracle when flushing the session
by Mark Müller (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-771?page=com... ]
Mark Müller commented on HB-771:
--------------------------------
If one has to stick to JDK 1.3 (like me) it may help to change the "Statement cache size" to 0 for the Datasource in the Websphere console. At least this has helped me.
> NullPointerException from oracle when flushing the session
> ----------------------------------------------------------
>
> Key: HB-771
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HB-771
> Project: Hibernate2
> Type: Bug
> Components: core
> Versions: 2.1
> Environment: hibernate 2.1, Oracle9i, WAS 5.1.0 JRE 1.4.1
> Reporter: Hadi Mallah
> Priority: Critical
>
>
> Hi,
> I just recently started using hibernate for my O/R mapping, after using Toplink for sometime.
> I have some issues and questions hopefully can be cleared out.
> Facts/environment:
> 1- We've created a simple thin layer around hibernate for the developer to interface with instead of going directly to hibernate APIs.
> 2- We are using Websphere studio 5.1.1 (WAS 5.1.0 and JRE 1.4.1)
> 3- hibernate 2.1
> 4- JTATransactionFactory, WebSphereTransactionManagerLookup,
> DatasourceConnectionProvider, OracleDialect, TreeCacheProvider (JBoss)
> 5- Session façade -> CMT (transaction-type=Container)
> 6- oracle.jdbc.xa.client.OracleXADataSource, ojdbc14.jar
> 7- We keep the session in a ThreadLocal, to make sure we hold the session for the current executing thread. We close the session when all work is completed. Since we depend on WebSphere JTA Tranaction Manager, we don't explicitly commit or rollback. We open the session, execute the action, flush, and then close the session - that all in the session façade (CMT).
> Issues:
> - I have been testing hibernate with Websphere studio 5.1.0 (WAS 5.0 and JRE 1.3) before, and it was working perfectly, then after I upgraded to Websphere studio 5.1.1 (WAS 5.1.0 and JRE 1.4.1), the problems started:
> 1- TransactionManagerFactory class package was changed in WAS
> 5.1. So basically it's as following:
> WAS 4.0: c com.ibm.ejs.jts.jta.JTSXA
> WAS 5.0: com.ibm.ejs.jts.jta.TransactionManagerFactory
> WAS 5.1: com.ibm.ws.Transaction.TransactionManagerFactory
> So I had to apply the change in
> net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
> I realized now that other people fixed it in this forum. so skip this one.
> 2- A strange problem has started, the first instance of an
> operation regardless if it is create, update, or delete works
> fine, then I the second time I try to do another create, update
> or delete, and when I try to flush the session, I get an oracle
> NullPointerException:
> java.lang.NullPointerException
> at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
> at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
> at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.resetStatement(WSJdbcConnection.java:1719)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1415)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1381)
> at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:230)
> at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:57)
> at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:105)
> at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:461)
> at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:443)
> at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
> at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
> at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2261)
> at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
> I go around this problem by catching the exception, clearing the
> session, and trying again, then it works fine the second time.
> I'm not sure, if the problem is a threading issues or what? What
> I know is I don't want it to be solved this way, although it is
> apparently not affecting the performance that much.
> Keep in mind that the same code works fine with the previous
> environment WAS 5.0 and JRE 1.3.
> And it happens either if I set transaction.manager_lookup_class
> to WebSphereTransactionManagerLookup or not.
> - It seems that after I do a session flush, data gets commited, if I fire a RuntimeException after flushing Websphere JTA Tranaction Manager doesn't rollback. Do I have to call rollback my self, am I allowed to rollback if Websphere JTA Tranaction Manager is demecrating the tranasctions, then whats the purpose of using Websphere JTA Tranaction Manager?
> Thanks,
> Hadi
--
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, 6 months
[Hibernate-JIRA] Commented: (HB-1331) Aliases in the SELECT clause will be used in the ORDER BY clause for the MySQL dialect
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-1331?page=co... ]
Diego Pires Plentz commented on HB-1331:
----------------------------------------
Ingres has the same problem, so, I think that "requiresAliasForSorting()" could become a part of Dialects. What about that?
> Aliases in the SELECT clause will be used in the ORDER BY clause for the MySQL dialect
> --------------------------------------------------------------------------------------
>
> Key: HB-1331
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HB-1331
> Project: Hibernate2
> Type: Patch
> Components: core
> Versions: 2.1.7
> Environment: Linux 2.6.8, MySQL 4.1.7, Hibernate 2.1.7c, Java 1.5
> Reporter: Jarod
> Priority: Minor
> Attachments: patchfile-mySQL-aliases
>
> Original Estimate: 0 minutes
> Remaining: 0 minutes
>
> This patch is a temporary fix to address the MySQL bug that prevents sorting by aggregate functions, a pretty common task for a database.
> It parses the generated SQL SELECT clause for aliases, and then replaces the corosponding columns in the ORDER BY clause with the alias. This is the current workaround for the MySQL bug.
> For more background information, see: http://forum.hibernate.org/viewtopic.php?t=925363
> For more details on the MySQL bug, see: http://bugs.mysql.com/bug.php?id=5478
> To use the patch, copy the lines below, starting with the first diff all the way to the end, to a file called patchfile. Then run `patch -lp0 < patchfile` from the directory that contains the hibernate-2.1 directory.
> diff -ru hibernate-2.1.7c/src/net/sf/hibernate/dialect/Dialect.java hibernate-2.1/src/net/sf/hibernate/dialect/Dialect.java
> --- hibernate-2.1.7c/src/net/sf/hibernate/dialect/Dialect.java 2004-11-23 11:47:39.000000000 -0600
> +++ hibernate-2.1/src/net/sf/hibernate/dialect/Dialect.java 2004-11-28 23:46:46.000000000 -0600
> @@ -180,7 +180,15 @@
> public boolean qualifyIndexName() {
> return true;
> }
> -
> +
> + /**
> + * Does this dialect require an alias for functions in the order by clause?+ * @return boolean
> + */
> + public boolean requiresAliasForSorting() {
> + return false;
> + }
> +
> /**
> * Does this dialect support the <tt>FOR UPDATE</tt> syntax?
> * @return boolean
> diff -ru hibernate-2.1.7c/src/net/sf/hibernate/dialect/MySQLDialect.java hibernate-2.1/src/net/sf/hibernate/dialect/MySQLDialect.java
> --- hibernate-2.1.7c/src/net/sf/hibernate/dialect/MySQLDialect.java 2004-11-23 11:47:38.000000000 -0600
> +++ hibernate-2.1/src/net/sf/hibernate/dialect/MySQLDialect.java 2004-11-28 23:46:46.000000000 -0600
> @@ -219,6 +219,10 @@
> return StringHelper.UNDERSCORE;
> }
>
> + public boolean requiresAliasForSorting() {
> + return true;
> + }
> +
> /**
> * Build an instance of the SQLExceptionConverter preferred by this dialect for
> * converting SQLExceptions into Hibernate's JDBCException hierarchy. The default
> diff -ru hibernate-2.1.7c/src/net/sf/hibernate/sql/QuerySelect.java hibernate-2.1/src/net/sf/hibernate/sql/QuerySelect.java
> --- hibernate-2.1.7c/src/net/sf/hibernate/sql/QuerySelect.java 2004-11-23 11:47:38.000000000 -0600
> +++ hibernate-2.1/src/net/sf/hibernate/sql/QuerySelect.java 2004-11-28 23:47:58.000000000 -0600
> @@ -1,8 +1,10 @@
> //$Id: QuerySelect.java,v 1.12 2004/06/04 05:43:48 steveebersole Exp $
> package net.sf.hibernate.sql;
>
> +import java.util.HashMap;
> import java.util.HashSet;
> import java.util.Iterator;
> +import java.util.StringTokenizer;
>
> import net.sf.hibernate.dialect.Dialect;
> import net.sf.hibernate.util.StringHelper;
> @@ -19,6 +21,7 @@
> private StringBuffer orderBy = new StringBuffer();
> private StringBuffer having = new StringBuffer();
> private boolean distinct=false;
> + private Dialect dialect = null;
>
> private static final HashSet DONT_SPACE_TOKENS = new HashSet();
> static {
> @@ -50,6 +53,7 @@
> }
>
> public QuerySelect(Dialect dialect) {
> + this.dialect = dialect;
> joins = new QueryJoinFragment(dialect, false);
> }
>
> @@ -126,10 +130,59 @@
> }
> if ( groupBy.length() > 0 ) buf.append(" group by ").append( groupBy.toString() );
> if ( having.length() > 0 ) buf.append(" having ").append( having.toString() );
> - if ( orderBy.length() > 0 ) buf.append(" order by ").append( orderBy.toString() );
> + if ( orderBy.length() > 0 ) {
> + if (dialect.requiresAliasForSorting()) {
> + //alias order by
> + buf.append(" order by ").append( aliasedOrder(select.toString(), orderBy.toString()) );
> + } else {
> + buf.append(" order by ").append( orderBy.toString() );
> + }
> + }
> return buf.toString();
> }
>
> + private String aliasedOrder(String select, String order) {
> + StringTokenizer st = new StringTokenizer(select, StringHelper.COMMA);
> + HashMap map = new HashMap();
> + String as = " as ";
> + while (st.hasMoreTokens()) {
> + String token = st.nextToken().trim();
> + int i = token.indexOf(as);
> + map.put(token.substring(0, i), token.substring(i + as.length(), token.length()));
> + }
> + st = new StringTokenizer(order, StringHelper.COMMA);
> + StringBuffer sb = new StringBuffer();
> + while (st.hasMoreTokens()) {
> + String token = st.nextToken().trim();
> + System.out.println(token);
> +
> + //the order by token may contain desc or asc
> + int directionIndex = token.indexOf(' ');
> + if (directionIndex == -1) {
> + directionIndex = token.indexOf(StringHelper.CLOSE_PAREN);
> + }
> + String direction = null;
> + if (directionIndex != -1) {
> + direction = token.substring(directionIndex+1, token.length());
> + token = token.substring(0, directionIndex+1).trim();
> + }
> +
> + String alias = (String)map.get(token);
> + if (alias==null) {
> + sb.append(token);
> + } else {
> + sb.append(alias);
> + }
> + if (direction != null) {
> + sb.append(' ').append(direction);
> + }
> + if (st.hasMoreTokens()) {
> + sb.append(StringHelper.COMMA_SPACE);
> + }
> + }
> + return sb.toString();
> + }
> +
> private static void appendTokens(StringBuffer buf, Iterator iter) {
> boolean lastSpaceable=true;
> boolean lastQuoted=false;
--
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, 6 months
[Hibernate-JIRA] Updated: (HHH-1901) Filtering on superclass property problem
by Juan Ignacio Cidre (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901?page=all ]
Juan Ignacio Cidre updated HHH-1901:
------------------------------------
Attachment: test.tar.gz
Here I attach a tar.gz file with all the files I posted previously
> Filtering on superclass property problem
> ----------------------------------------
>
> Key: HHH-1901
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901
> Project: Hibernate3
> Type: Bug
> Versions: 3.1.3
> Environment: Hibernate 3.1.3 on Oracle 9i
> Reporter: Juan Ignacio Cidre
> Attachments: test.tar.gz
>
>
> I have three classes Order, Advertisements and Creatives.
> Advertisements is subclass of Creatives
> Order has a one-to-many to Advertisements
> That one-to-many has a filter. The condition has to do with a property of Creative, the Advertisements superclass.
> This is the Order to Advertisements mapping with a filter on deletionStatusId that is a field of Creative.
> <set name="ads" inverse="true" lazy="true">
> <key column="orderId"/>
> <one-to-many class="com.inceptor.domain.msn.Advertisement"/>
> <filter name="deletionStatusFilter" condition="deletionStatusId = 0"/>
> </set>
> This is the Creative mapping with the deletionStatusId, which is mapped as a component. It is a Enum in Java.
> <component name="deletionStatus"
> class="com.inceptor.domain.core.DeletionStatusType">
> <property name="number" column="deletionStatusId" />
> </component>
> I would expected an sql that appends a where condition like [superclass (Creative) table alias].deletionStatusId instead I received [subclass (Advertisements) table alias].deletionStatusId
> This generates a DB error.
> Follows the generated query
> Note ads0_ instead of ads0_1_
> select ads0_.orderId as orderId1_, ads0_.id as id1_, ads0_.id as ID324_0_, ads0_1_.version as version324_0_, ads0_1_.searchEngineAccountId as searchEn3_324_0_, ads0_1_.creationTime as creation4_324_0_, ads0_1_.creatorId as creatorId324_0_, ads0_1_.modificationTime as modifica6_324_0_, ads0_1_.synchTime as synchTime324_0_, ads0_1_.modifierId as modifierId324_0_, ads0_1_.deletionStatusId as deletion9_324_0_, ads0_1_.deleterId as deleterId324_0_, ads0_1_.pushError as pushError324_0_, ads0_.seId as seId418_0_, ads0_.title as title418_0_, ads0_.description as descript4_418_0_, ads0_.displayURL as displayURL418_0_, ads0_.destinationURL as destinat6_418_0_, ads0_.originalDestinationURL as original7_418_0_, ads0_.orderId as orderId418_0_ from MSN_Advertisements ads0_ inner join GTK_Creatives ads0_1_ on ads0_.id=ads0_1_.ID where ads0_.deletionStatusId = 0 and ads0_.orderId=?
--
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, 6 months
[Hibernate-JIRA] Updated: (HHH-1668) PersistentSet write methods mark collection as dirty even if entry is not written
by Josh Moore (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1668?page=all ]
Josh Moore updated HHH-1668:
----------------------------
Attachment: hhh-1668.tests.txt
hhh-1668.tests.txt contains tests for PersistentBag and PersistentList, Steve. (Copied from your PSet and PMap tests). Also added to PMapTest a preliminary check for the SetProxy returned by PMap.keySet() and PMap.values(). The iterator calls all seem to be harmless, at least I can't think of a way to make the tests fail. And PIdentifierBag needs testing but I'm too unfamiliar with that.
> PersistentSet write methods mark collection as dirty even if entry is not written
> ---------------------------------------------------------------------------------
>
> Key: HHH-1668
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1668
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.3
> Reporter: Koda Janh
> Assignee: Steve Ebersole
> Fix For: 3.2.1
> Attachments: PersistentSet.patch, hhh-1668.tests.txt
>
> Original Estimate: 5 minutes
> Remaining: 5 minutes
>
> PersistentSet gets marked as dirty even if it hasn't changed. This has negative implications for concurrency because the optimistic-lock version is incremented and StaleObjectStateException is thrown even if the underlying data remains unchanged.
> I stepped through the code and narrowed down the problem to a bug in PersistentSet.add(). A simple fix is to replace:
> if (exists==null) {
> write();
> return set.add(value);
> }
> by:
> if (exists==null) {
> boolean result = set.add(value);
> if (result) {
> write();
> }
> return result;
> }
> I verified that this fixed the problem on my end. The old code was always marking the Set as dirty whereas the new code only does so if it actually has been modified. Please commit this patch.
--
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, 6 months
[Hibernate-JIRA] Commented: (HHH-1729) Oracle9Dialect LockMode.UPGRADE conflicts with setMaxResults
by Christian Bauer (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1729?page=c... ]
Christian Bauer commented on HHH-1729:
--------------------------------------
Do you have a patch ready?
> Oracle9Dialect LockMode.UPGRADE conflicts with setMaxResults
> ------------------------------------------------------------
>
> Key: HHH-1729
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1729
> Project: Hibernate3
> Type: Bug
> Versions: 3.1
> Environment: Hibernate 1.1, Oracle 10g release 2 (also tested with 10g release 1).
> Reporter: Mark Lewis
> Priority: Minor
>
>
> When executing a simple HQL select from in Oracle, attempting to specify LockMode.UPGRADE to generate a "for update" clause while specifying a setMaxResults(10) causes an Oracle-00904: Invalid identifier exception. The same query works fine with several other tested dialects.
> The reason is that the generated SQL refers to a column by its actual column name, instead of the column alias assigned to it. Consider the following example:
> select * from ( select scheduleel0_.elementId as elementId22_ from ScheduleElement scheduleel0_ ) where rownum <= ? for update of scheduleel0_.elementId
> This should be "for update of elementId22_", because "scheduleel0_.elementId" can't be referenced at this scope in the SQL.
> I've dug through the code but I think the fix will require a more knowledge of Hibernate's guts than I've got. The offending SQL is inserted in org.hibernate.sql.ForUpdateFragment.toFragmentString(), but the ForUpdateFragment class doesn't know what the column aliases are for each real column, so it would need some way of getting that information.
> The HQL which causes the problem is as follows:
> from ScheduleElement as element where element.runnable=true and element.scheduleHead=true
> (I don't think it matters, but ScheduleElement is the root of a class hierarchy defined using joined-subclass)
> It is executed using the following Java code:
> session.createQuery(seeAboveForTheQueryString)
> .setLockMode("element", LockMode.UPGRADE)
> .setMaxResults(10)
> .list();
> Here is the bad SQL created from the HQL:
> -- Selecting all columns and left joining on subclass tables omitted for brevity
> select * from ( select scheduleel0_.elementId as elementId22_ from ScheduleElement scheduleel0_ ) where rownum <= ? for update of scheduleel0_.elementId
--
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, 6 months
[Hibernate-JIRA] Commented: (HHH-1729) Oracle9Dialect LockMode.UPGRADE conflicts with setMaxResults
by Olivier Jolly (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1729?page=c... ]
Olivier Jolly commented on HHH-1729:
------------------------------------
The problem is still present in version 3.2.0rc4 and we are also badly annoyed with this one.
> Oracle9Dialect LockMode.UPGRADE conflicts with setMaxResults
> ------------------------------------------------------------
>
> Key: HHH-1729
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1729
> Project: Hibernate3
> Type: Bug
> Versions: 3.1
> Environment: Hibernate 1.1, Oracle 10g release 2 (also tested with 10g release 1).
> Reporter: Mark Lewis
> Priority: Minor
>
>
> When executing a simple HQL select from in Oracle, attempting to specify LockMode.UPGRADE to generate a "for update" clause while specifying a setMaxResults(10) causes an Oracle-00904: Invalid identifier exception. The same query works fine with several other tested dialects.
> The reason is that the generated SQL refers to a column by its actual column name, instead of the column alias assigned to it. Consider the following example:
> select * from ( select scheduleel0_.elementId as elementId22_ from ScheduleElement scheduleel0_ ) where rownum <= ? for update of scheduleel0_.elementId
> This should be "for update of elementId22_", because "scheduleel0_.elementId" can't be referenced at this scope in the SQL.
> I've dug through the code but I think the fix will require a more knowledge of Hibernate's guts than I've got. The offending SQL is inserted in org.hibernate.sql.ForUpdateFragment.toFragmentString(), but the ForUpdateFragment class doesn't know what the column aliases are for each real column, so it would need some way of getting that information.
> The HQL which causes the problem is as follows:
> from ScheduleElement as element where element.runnable=true and element.scheduleHead=true
> (I don't think it matters, but ScheduleElement is the root of a class hierarchy defined using joined-subclass)
> It is executed using the following Java code:
> session.createQuery(seeAboveForTheQueryString)
> .setLockMode("element", LockMode.UPGRADE)
> .setMaxResults(10)
> .list();
> Here is the bad SQL created from the HQL:
> -- Selecting all columns and left joining on subclass tables omitted for brevity
> select * from ( select scheduleel0_.elementId as elementId22_ from ScheduleElement scheduleel0_ ) where rownum <= ? for update of scheduleel0_.elementId
--
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, 6 months