[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1479) Incompatibility of Hibernate 3.1 and JTOpen JDBC drivers for IBM AS/400
Peter Francq (JIRA)
noreply at atlassian.com
Thu Oct 26 03:34:06 EDT 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1479?page=comments#action_24992 ]
Peter Francq commented on HHH-1479:
-----------------------------------
If your application does not run on different backends then I would suggest to use a sequence generator.
The native generator picks identity, sequence or hilo depending upon the capabilities of the underlying database.
As DB2 on AS400 support sequence I would put somthing like this in my mapping file
<id name="id" type="long" column="person_id">
<generator class="sequence">
<param name="sequence">person_id_sequence</param>
</generator>
</id>
We actually did it to avoid the same problem.
Greetz,
Peter Francq
> Incompatibility of Hibernate 3.1 and JTOpen JDBC drivers for IBM AS/400
> -----------------------------------------------------------------------
>
> Key: HHH-1479
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1479
> Project: Hibernate3
> Type: Patch
> Versions: 3.1
> Environment: Hibernate 3.1
> JDBC driver: JTOpen (for IBM AS/400) http://jt400.sourceforge.net
> Reporter: Davide Rogora
>
>
> Hello,
> I've noticed that from version 3.1 Hibernate, when calling JDBC driver for INSERT statement, uses the following prepareStatement method:
> prepareStatement(String sql, String[] columnNames)
> instead of the following
> prepareStatement(String sql, int autoGeneratedKeys)
> used since versione 3.0.x
> the problem is that JDBC driver for AS/400 (project JTOpen on sourceforge: http://jt400.sourceforge.net) doesn't support the method prepareStatement(String sql, String[] columnNames) so it's not possible to use Hibernate 3.1 with AS/400
> I've also noticed that other open source drivers that support this method (for example MySQL Jdbcconnector or JTDS for Ms-SQLServer) have implemented it using a workaround; infact they call the "old" prepareStatement(String sql, int autoGeneratedKeys) method ignoring the content of the columnNames array.
> Here is the source of the jtds implementation:
> -------------------------------------------------------------------------------
> public PreparedStatement prepareStatement(String sql, String[] columnNames)
> throws SQLException {
> if (columnNames == null) {
> throw new SQLException(
> Messages.get("error.generic.nullparam", "prepareStatement"),"HY092");
> } else if (columnNames.length != 1) {
> throw new SQLException(
> Messages.get("error.generic.needcolname", "prepareStatement"),"HY092");
> }
> return prepareStatement(sql, JtdsStatement.RETURN_GENERATED_KEYS);
> }
> -------------------------------------------------------------------------------
> So I'm asking to the Hibernate team if it's possible to use the old method prepareStatement(String sql, int autoGeneratedKeys) in the future releases of Hibernate.
> Thanks,
> Davide Rogora.
--
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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list