chill - hibernate just works (TM) - inside JBoss or out ! ...

The gay is slandering hiberbate here and jboss there - Simon - U say U not going to use jboss in prod anyway !

*** From the hibernate list We conclude this Simon (Jasons Brother ...heeh) is using a generation totally wrong in its function ... and therefore has the right it seems to waste our time and goodwill ,,,

*** Start Hibernate dev list
From: Max Rydahl Andersen <[EMAIL PROTECTED]>
Re: JBoss and Hibernate �
2002-11-29 09:09

This is expected behavior, snippet from the docs:

hilo.long

Uses a hi/lo algorithm to efficiently generate identifiers of type long,
given a table and column (by default "hibernate_unique_key" and "next"
respectively) as a source of hi values. The hi/lo algorithm generates
identifiers that are unique only for a particular database. Do not use this
generator with connections enlisted with JTA or with a user-supplied
connection.

Notice the last line :)

Workaround: Make your own generator that makes a direct connection to do the
same thing :)

Maybe we should provide such a beast with hibernate ?

/max

----- Original Message -----
From: "Simon Stewart" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 29, 2002 5:56 PM
Subject: [Hibernate] JBoss and Hibernate


> Using JBoss 3.0.4, the Apple OS X JDK 1.4DP6 and Postgres 7.2.2 it is
> impossible to persist objects using Hibernate (beta4). When using code
> similar to:
>
> Person p = new Person();
> Session sess = Hibernate.openSession();
> sess.save( p ); // Exception thrown here
> // Close session properly.
>
> The following SQL exception is thrown:
>
> java.sql.SQLException: You cannot commit with autocommit set!
>
> This is ultimately caused by the HiLoGenerator while trying to set the
> persisted object's ID. If I try the same sort of thing with a
> Transaction:
>
> Person p = new Person();
> Session sess = Hibernate.openSession();
> Transaction tx = sess.beginTransaction();
> sess.save( p ); // Exception thrown here
> tx.commit();
> // Close session properly
>
> The exception:
>
> java.sql.SQLException: You cannot commit during a managed transaction!
>
> is thrown. This is again caused by the HiLoGenerator.
>
> As I had not seen this behaviour under previous versions of JBoss, I
> posted to the JBoss user list asking if anyone else had seen this
> problem. David Jencks, one of the JBoss developers, replied that:
>
> "Autocommit on is required by the jca spec, and should have been the
> case
> for 3.0 versions as well. You should endevour to make the transactions
> be
> controlled by the jboss tm/jta/cmt etc."
>
> Which fits with my error messages because I obtain my datasource from
> the JNDI (java:/DefaultDS, if that helps) The problem is that the
> HiLoGenerator (which my classes use) commits the changes that it has
> made to the underlying Hi/Lo table by calling Connection.commit() (line
> 131 in HiLoGenerator.java, I think) rather than using a transaction,
> which would work. Are there any known work-arounds to this problem
> other than generating the IDs myself? Should I mark it as a bug on the
> sourceforge pages?
>
> Regards,
*** End Hibernate dev list

s�ndagen den 1 december 2002 kl 03.00 skrev Igor Fedorenko:

David Jencks wrote:
Why do you think this answer is correct? Does the jdbc spec say so? I
think if you are in a managed transaction, autocommit should be reported
true -- you didn't set autocommit (false), and you can't control when the
transaction is committed.
JDBC 2.0 Standard Extension API, section 7.1
<quote>
Because transaction boundaries are controlled by the middle-tier server, the application
code may not call the Connection.commit() or Connection.rollback() methods.
These methods will throw an SQLException if they are called. In addition, the Connection
object that is returned by a DataSource when distributed transactions are being
done has autoCommit turned off by default. Attempting to enable autoCommit by calling
Connection.setAutoCommit() with a value of true will throw an SQLException.
The example below illustrates a typical sequence of JDBC API operations that an application
developer would write in a middle-tier environment where distributed transactions
are being used. The example assumes that ds is of type DataSource.
</quote>

At the same time I agree with you that it should not matter much to applications.

Also, why won't the same patch work for xa datasources with the newer
wrapper?
As far as I remember XAWrappedConnection (or whatever its name) does not manage inManagedTransaction, i.e. inManagedTransaction is always false for xa connections. It was awhile ago but I remember that I've reviewed the code for possible related problems I could not find any.

Thanks
david jencks
On 2002.11.29 10:59:16 -0500 Igor Fedorenko wrote:
Simon Stewart wrote:

Off list I had a reply to this email, the gist of the email (and my reply) was:


I encountered this problem when migrating an application from JBoss
3.0.0 to 3.0.4. I came back to 3.0.0 without investigating the
problem.


The same problem occurs in 3.2.0beta2, so unless you're thinking of never upgrading it's going to become an issue at some point. However, the fact that it worked in 3.0.0 is interesting.

Perhaps someone (Dain?) might be able to shed some light on this? The problem appears to boil down to the fact that datasources returned by JBoss now have autocommit on (at least for Postgres) Any reason for
this
change? And does anyone know of a work-around?
I am not sure if this is relevant to your problem but there is a bug in 3.2 and 4.0 that makes all JDBC connections returned by JBoss always *report* that auto commit is set to true. Below is very simple patch that is supposed to fix the problem for local-tx datasource (I do not use local-tx and could not test if the patch works). XA datasources have similar problem but I do not have a solution yet. Note that this has nothing to do with actual db connection settings, it is jdbc wrapper that misbehaves.


Index: BaseWrapperManagedConnection.jpp
===================================================================
RCS file: /cvsroot/jboss/jbosscx/src/main/org/jboss/resource/adapter/jdbc/ BaseWrapperManagedConnection.jpp,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 BaseWrapperManagedConnection.jpp
--- BaseWrapperManagedConnection.jpp 7 Nov 2002 21:04:08
-0000 1.1.2.1
+++ BaseWrapperManagedConnection.jpp 29 Nov 2002 15:54:05 -0000
@@ -324,14 +324,13 @@

}

-
/**
* Get the JdbcAutoCommit value.
* @return the JdbcAutoCommit value.
*/
boolean isJdbcAutoCommit()
{
- return jdbcAutoCommit;
+ return inManagedTransaction? false: jdbcAutoCommit;
}

/**

--
Igor Fedorenko
Think smart. Think automated. Think Dynamics.
www.thinkdynamics.com





-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
--
Igor Fedorenko
Think smart. Think automated. Think Dynamics.
www.thinkdynamics.com



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to