Team.
Thanks for the posts above.
I have got it working with Hibernate with Microsoft ms access odbc, including inserts and reads with identity.
I am using hibernate 3.0 , JDK 1.4 and Microsoft ms access 200.
Here is the dialect class:-
Code:
package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.cfg.Environment;
/**
* @author Suchak.Jani
*/
public class MSAccessDialect extends Dialect {
public MSAccessDialect() {
super();
registerColumnType( Types.BIT, "BIT" );
registerColumnType( Types.BIGINT, "INTEGER" );
registerColumnType( Types.SMALLINT, "SMALLINT" );
registerColumnType( Types.TINYINT, "BYTE" );
registerColumnType( Types.INTEGER, "INTEGER" );
registerColumnType( Types.CHAR, "VARCHAR(1)" );
registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
registerColumnType( Types.FLOAT, "DOUBLE" );
registerColumnType( Types.DOUBLE, "DOUBLE" );
registerColumnType( Types.DATE, "DATETIME" );
registerColumnType( Types.TIME, "DATETIME" );
registerColumnType( Types.TIMESTAMP, "DATETIME" );
registerColumnType( Types.VARBINARY, "VARBINARY($l)" );
registerColumnType( Types.NUMERIC, "NUMERIC" );
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE,NO_BATCH);
}
public String getIdentityColumnString() {
//return " counter ";
return "not null auto_number";
}
public String getIdentitySelectString() {
return "select @@IDENTITY";
}
}
Here is a test xml file which works :-
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.suchak.hibernatetest.domainobjects.Person" table="Person">
<id
name="ID"
column="ID"
>
<!-- The above ID is an Interger in java and Autonumber in Microsoft ms access -->
<generator class="identity"/>
</id>
<property name="firstName">
<column name="FirstName"/>
</property>
<property name="lastName">
<column name="LastName"/>
</property>
</class>
</hibernate-mapping>
Note:- Just to restate, the problems of still not being able to use Long still exist due to issues of the odbc driver. It has nothing to do with Hibernate.
Regards
Suchak Jani