Thomas, here are the files needed for the reproduction of the problem. If 
you delete "with ur" grammar statement at the method 
DriverDaoService.getAllDrivers() the test DriverTestH2.testGetAllfDrivers() 
will be completed successfully.

Regards, Alexey


On Monday, December 23, 2013 3:34:23 PM UTC+3, Thomas Mueller wrote:
>
> Hi,
>
> Did you use the IBM DB2 mode? To do that, append ";MODE=DB2" to the 
> database URL. If it still doesn't work, could you post a reproducible test 
> case?
>
> Regards,
> Thomas
>
>
> On Mon, Dec 23, 2013 at 1:10 PM, Alexey Kalugin 
> <[email protected]<javascript:>
> > wrote:
>
>> I took the latest automated build having followed the link (
>> http://www.h2database.com/automated/h2-latest.jar) however that didn't 
>> help me as the issue still persists. Can you please let me knew which build 
>> will the issue be resolved in?
>>
>>
>> On Mon, Dec 23, 2013 at 2:21 PM, Noel Grandin 
>> <[email protected]<javascript:>
>> > wrote:
>>
>>> The automated build links are here:
>>>
>>> http://h2database.com/html/build.html#automated
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "H2 Database" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/h2-database/I9R1bBS2WRw/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> [email protected] <javascript:>.
>>>
>>> To post to this group, send email to [email protected]<javascript:>
>>> .
>>> Visit this group at http://groups.google.com/group/h2-database.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "H2 Database" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/h2-database.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Attachment: Driver.hbm.xml
Description: XML document

package model;
import java.util.Date;


public class Driver {
	private long id;
	
	public String firstName;
	public String lastName;
	public Date birthDate;
	
	public Driver(String firstName, String lastName, Date birthDate) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.birthDate = birthDate;
	}
	
	public Driver() {}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
}

Attachment: driver-init.xml
Description: XML document

package testing;

import java.io.File;
import java.nio.charset.Charset;

import model.Driver;

import org.dbunit.DBTestCase;
import org.dbunit.PropertiesBasedJdbcDatabaseTester;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
import org.dbunit.operation.DatabaseOperation;
import org.h2.tools.RunScript;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import dao.DriverDaoService;
import dao.HibernateUtil;

public class DriverTestH2 extends DBTestCase {
	private FlatXmlDataSet loadedDataSet;
	
	public DriverTestH2(String name) throws Exception {
		super(name);
		
		RunScript.execute("jdbc:h2:mem:test;MODE=DB2;DB_CLOSE_DELAY=-1", "admin", "admin", "src\\testing\\schema.sql", Charset.forName("UTF-8"), false);
		
		System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, "org.h2.Driver");
		System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, "jdbc:h2:mem:test;MODE=DB2;DB_CLOSE_DELAY=-1");
		System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, "admin" );
        System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, "admin" );
	}
	
	@Override
	protected IDataSet getDataSet() throws Exception {
		loadedDataSet = new FlatXmlDataSetBuilder().build(new File("src\\testing\\driver-init.xml"));
		
		return loadedDataSet;
	}
	
	protected DatabaseOperation getSetUpOperation() throws Exception
    {
        return DatabaseOperation.INSERT;
    }

    protected DatabaseOperation getTearDownOperation() throws Exception
    {
        return DatabaseOperation.DELETE;
    }
    
    public void testDriverDataLoaded() throws Exception {
		Assert.assertNotNull(loadedDataSet);
		
		int rowCount = loadedDataSet.getTable("Driver").getRowCount();
		
		Assert.assertEquals(3, rowCount);
	}
    
    public void testGetAllfDrivers() {
    	int countOfDrivers = DriverDaoService.getAllDrivers().size();
    	Assert.assertEquals(3, countOfDrivers);
    }
}

Attachment: hibernate_test.cfg.xml
Description: XML document

create table if not exists Driver (
  ID int identity primary key,
  FirstName varchar,
  LastName varchar,
  BirthDate date
)
package dao;


import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import model.Driver;

public class DriverDaoService {
	public static List<Driver> getAllDrivers() {
	Session session = HibernateUtil.getSessionFactory().openSession();
		
		Transaction transaction = session.beginTransaction();
		
		
		List<Driver> drivers = session.createSQLQuery("select * from Driver with ur").addEntity(Driver.class).list();
		
		transaction.commit();
		session.close();
		
		return drivers;
	}
}
package dao;



import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtil {
	private static SessionFactory sessionFactory;
	
	static {
		Configuration configuration = new Configuration();
		configuration.configure("testing\\hibernate_test.cfg.xml");
		
		//configuration.configure("dao\\hibernate.cfg.xml");
		
		ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
		sessionFactory = configuration.buildSessionFactory(serviceRegistry);
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}

Reply via email to