org.hibernate.dialect.HSQLDialect Java Examples

The following examples show how to use org.hibernate.dialect.HSQLDialect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateJpaVendorAdapter.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
@Nullable
protected Class<?> determineDatabaseDialectClass(Database database) {
	switch (database) {
		case DB2: return DB2Dialect.class;
		case DERBY: return DerbyTenSevenDialect.class;
		case H2: return H2Dialect.class;
		case HANA: return HANAColumnStoreDialect.class;
		case HSQL: return HSQLDialect.class;
		case INFORMIX: return InformixDialect.class;
		case MYSQL: return MySQL5Dialect.class;
		case ORACLE: return Oracle12cDialect.class;
		case POSTGRESQL: return PostgreSQL95Dialect.class;
		case SQL_SERVER: return SQLServer2012Dialect.class;
		case SYBASE: return SybaseDialect.class;
		default: return null;
	}
}
 
Example #2
Source File: HibernateJpaVendorAdapter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
@SuppressWarnings("deprecation")
protected Class<?> determineDatabaseDialectClass(Database database) {
	switch (database) {
		case DB2: return DB2Dialect.class;
		case DERBY: return DerbyDialect.class;  // DerbyDialect deprecated in 4.x
		case H2: return H2Dialect.class;
		case HSQL: return HSQLDialect.class;
		case INFORMIX: return InformixDialect.class;
		case MYSQL: return MySQL5Dialect.class;
		case ORACLE: return Oracle9iDialect.class;
		case POSTGRESQL: return PostgreSQLDialect.class;  // PostgreSQLDialect deprecated in 4.x
		case SQL_SERVER: return SQLServer2008Dialect.class;
		case SYBASE: return org.hibernate.dialect.SybaseDialect.class;  // SybaseDialect deprecated in 3.6 but not 4.x
		default: return null;
	}
}
 
Example #3
Source File: HibernateJpaVendorAdapter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
@Nullable
protected Class<?> determineDatabaseDialectClass(Database database) {
	switch (database) {
		case DB2: return DB2Dialect.class;
		case DERBY: return DerbyTenSevenDialect.class;
		case H2: return H2Dialect.class;
		case HANA: return HANAColumnStoreDialect.class;
		case HSQL: return HSQLDialect.class;
		case INFORMIX: return InformixDialect.class;
		case MYSQL: return MySQL5Dialect.class;
		case ORACLE: return Oracle12cDialect.class;
		case POSTGRESQL: return PostgreSQL95Dialect.class;
		case SQL_SERVER: return SQLServer2012Dialect.class;
		case SYBASE: return SybaseDialect.class;
		default: return null;
	}
}
 
Example #4
Source File: HibernateJpaVendorAdapter.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
@SuppressWarnings("deprecation")
protected Class<?> determineDatabaseDialectClass(Database database) {
	switch (database) {
		case DB2: return DB2Dialect.class;
		case DERBY: return DerbyDialect.class;  // DerbyDialect deprecated in 4.x
		case H2: return H2Dialect.class;
		case HSQL: return HSQLDialect.class;
		case INFORMIX: return InformixDialect.class;
		case MYSQL: return MySQLDialect.class;
		case ORACLE: return Oracle9iDialect.class;
		case POSTGRESQL: return PostgreSQLDialect.class;  // PostgreSQLDialect deprecated in 4.x
		case SQL_SERVER: return SQLServerDialect.class;
		case SYBASE: return org.hibernate.dialect.SybaseDialect.class;  // SybaseDialect deprecated in 3.6 but not 4.x
		default: return null;
	}
}
 
Example #5
Source File: ASTParserLoadingTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Copied from {@link HQLTest#testExpressionWithParamInFunction}
 */
public void testExpressionWithParamInFunction() {
	Session s = openSession();
	s.beginTransaction();
	s.createQuery( "from Animal a where abs(a.bodyWeight-:param) < 2.0" ).setLong( "param", 1 ).list();
	s.createQuery( "from Animal a where abs(:param - a.bodyWeight) < 2.0" ).setLong( "param", 1 ).list();
	if ( ! ( getDialect() instanceof HSQLDialect ) ) {
		// HSQLDB does not like the abs(? - ?) syntax...
		s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
	}
	s.createQuery( "from Animal where lower(upper(:foo)) like 'f%'" ).setString( "foo", "foo" ).list();
	s.createQuery( "from Animal a where abs(abs(a.bodyWeight - 1.0 + :param) * abs(length('ffobar')-3)) = 3.0" ).setLong( "param", 1 ).list();
	s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setString( "bar", "xyz" ).list();
	if ( ! ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof MySQLDialect ) ) {
		s.createQuery( "from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0" ).setLong( "param", 1 ).list();
	}
	s.getTransaction().commit();
	s.close();
}
 
Example #6
Source File: LivingDocServerConfigurationActivator.java    From livingdoc-confluence with GNU General Public License v3.0 6 votes vote down vote up
public void initQuickInstallConfiguration() throws LivingDocServerException {
    LivingDocServerConfiguration customConfiguration = getConfiguration();

    Properties properties = new DefaultServerProperties();

    properties.remove("hibernate.connection.datasource"); // direct jdbc
    properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbc.JDBCDriver");
    properties.put("hibernate.connection.url", "jdbc:hsqldb:file:" + getConfluenceHome() + "/database/ldsdb");
    properties.put("hibernate.connection.username", "sa");
    properties.put("hibernate.connection.password", "");
    properties.put("hibernate.dialect", HSQLDialect.class.getName());

    configuration.setProperties(properties);

    setupDatabaseFromConfiguration(customConfiguration);
}
 
Example #7
Source File: MasterDetailTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testSelfManyToOne() throws Exception {

		//if (dialect instanceof HSQLDialect) return;

		Session s = openSession();
		Transaction t = s.beginTransaction();
		Master m = new Master();
		m.setOtherMaster(m);
		s.save(m);
		t.commit();
		s.close();
		s = openSession();
		t = s.beginTransaction();
		Iterator i = s.iterate("from Master");
		m = (Master) i.next();
		assertTrue( m.getOtherMaster()==m );
		if (getDialect() instanceof HSQLDialect) { m.setOtherMaster(null); s.flush(); }
		s.delete(m);
		t.commit();
		s.close();
	}
 
Example #8
Source File: FooBarTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testManyToManyBag() throws Exception {

		Session s = openSession();
		Baz baz = new Baz();
		Serializable id = s.save(baz);
		s.flush();
		s.connection().commit();
		s.close();

		s = openSession();
		baz = (Baz) s.load(Baz.class, id);
		baz.getFooBag().add( new Foo() );
		s.flush();
		s.connection().commit();
		s.close();

		s = openSession();
		baz = (Baz) s.load(Baz.class, id);
		assertTrue( !Hibernate.isInitialized( baz.getFooBag() ) );
		assertTrue( baz.getFooBag().size()==1 );
		if ( !(getDialect() instanceof HSQLDialect) ) assertTrue( Hibernate.isInitialized( baz.getFooBag().iterator().next() ) );
		s.delete(baz);
		s.flush();
		s.connection().commit();
		s.close();
	}
 
Example #9
Source File: UnionSubclassTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testQuerySubclassAttribute() {
	if ( getDialect() instanceof HSQLDialect ) {
		return; // TODO : why??
	}
	
	Session s = openSession();
	Transaction t = s.beginTransaction();
	Person p = new Person();
	p.setName("Emmanuel");
	p.setSex('M');
	s.persist(p);
	Employee q = new Employee();
	q.setName("Steve");
	q.setSex('M');
	q.setTitle("Mr");
	q.setSalary( new BigDecimal(1000) );
	s.persist(q);

	List result = s.createQuery("from Person where salary > 100").list();
	assertEquals( result.size(), 1 );
	assertSame( result.get(0), q );
	
	result = s.createQuery("from Person where salary > 100 or name like 'E%'").list();
	assertEquals( result.size(), 2 );		

	result = s.createCriteria(Person.class)
		.add( Property.forName("salary").gt( new BigDecimal(100) ) )
		.list();
	assertEquals( result.size(), 1 );
	assertSame( result.get(0), q );

	result = s.createQuery("select salary from Person where salary > 100").list();
	assertEquals( result.size(), 1 );
	assertEquals( ( (BigDecimal) result.get(0) ).intValue(), 1000 );
	
	s.delete(p);
	s.delete(q);
	t.commit();
	s.close();
}
 
Example #10
Source File: FumTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testCompositeKeyPathExpressions() throws Exception {
	Session s = openSession();
	s.find("select fum1.fo from Fum fum1 where fum1.fo.fum is not null");
	s.find("from Fum fum1 where fum1.fo.fum is not null order by fum1.fo.fum");
	if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof HSQLDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof PointbaseDialect) ) {
		s.find("from Fum fum1 where exists elements(fum1.friends)");
		if(!(getDialect() instanceof TimesTenDialect)) { // can't execute because TimesTen can't do subqueries combined with aggreations
			s.find("from Fum fum1 where size(fum1.friends) = 0");
		}
	}
	s.find("select elements(fum1.friends) from Fum fum1");
	s.find("from Fum fum1, fr in elements( fum1.friends )");
	s.connection().commit();
	s.close();
}
 
Example #11
Source File: CompositeUserTypeTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testCompositeUserType() {
	Session s = openSession();
	org.hibernate.Transaction t = s.beginTransaction();
	
	Transaction tran = new Transaction();
	tran.setDescription("a small transaction");
	tran.setValue( new MonetoryAmount( new BigDecimal(1.5), Currency.getInstance("USD") ) );
	s.persist(tran);
	
	List result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'USD'").list();
	assertEquals( result.size(), 1 );
	tran.getValue().setCurrency( Currency.getInstance("AUD") );
	result = s.createQuery("from Transaction tran where tran.value.amount > 1.0 and tran.value.currency = 'AUD'").list();
	assertEquals( result.size(), 1 );
	
	if ( !(getDialect() instanceof HSQLDialect) && ! (getDialect() instanceof Oracle9Dialect) ) {
	
		result = s.createQuery("from Transaction txn where txn.value = (1.5, 'AUD')").list();
		assertEquals( result.size(), 1 );
		result = s.createQuery("from Transaction where value = (1.5, 'AUD')").list();
		assertEquals( result.size(), 1 );
		
	}
	
	s.delete(tran);
	t.commit();
	s.close();
}
 
Example #12
Source File: HQLTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testOrderBy() throws Exception {
	assertTranslation( "from Animal an order by an.bodyWeight" );
	assertTranslation( "from Animal an order by an.bodyWeight asc" );
	assertTranslation( "from Animal an order by an.bodyWeight desc" );
	assertTranslation( "from Animal an order by sqrt(an.bodyWeight*4)/2" );
	assertTranslation( "from Animal an order by an.mother.bodyWeight" );
	assertTranslation( "from Animal an order by an.bodyWeight, an.description" );
	assertTranslation( "from Animal an order by an.bodyWeight asc, an.description desc" );
	if ( getDialect() instanceof HSQLDialect || getDialect() instanceof DB2Dialect ) {
		assertTranslation( "from Human h order by sqrt(h.bodyWeight), year(h.birthdate)" );
	}
}
 
Example #13
Source File: HQLTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testSelectDialectFunction() throws Exception {
	// From SQLFunctionsTest.testDialectSQLFunctions...
	if ( getDialect() instanceof HSQLDialect ) {
		assertTranslation( "select mod(s.count, 2) from org.hibernate.test.legacy.Simple as s where s.id = 10" );
		//assertTranslation( "from org.hibernate.test.legacy.Simple as s where mod(s.count, 2) = 0" );
	}
	assertTranslation( "select upper(human.name.first) from Human human" );
	assertTranslation( "from Human human where lower(human.name.first) like 'gav%'" );
	assertTranslation( "select upper(a.description) from Animal a" );
	assertTranslation( "select max(a.bodyWeight) from Animal a" );
}
 
Example #14
Source File: AssignmentTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
            setProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE, environment.getProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE));
        }
    };
}
 
Example #15
Source File: FileConversionServiceTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
            setProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE, environment.getProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE));
        }
    };
}
 
Example #16
Source File: MessageBundleTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
        }
    };
}
 
Example #17
Source File: ContextMappingConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(Environment.DIALECT, env.getProperty(Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(Environment.HBM2DDL_AUTO, env.getProperty(Environment.HBM2DDL_AUTO));
        }
    };
}
 
Example #18
Source File: SiteStatsTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
        }
    };
}
 
Example #19
Source File: AssignmentTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
            setProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE, environment.getProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE));
        }
    };
}
 
Example #20
Source File: FileConversionServiceTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
            setProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE, environment.getProperty(org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE));
        }
    };
}
 
Example #21
Source File: MessageBundleTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
        }
    };
}
 
Example #22
Source File: ContextMappingConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(Environment.DIALECT, env.getProperty(Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(Environment.HBM2DDL_AUTO, env.getProperty(Environment.HBM2DDL_AUTO));
        }
    };
}
 
Example #23
Source File: SiteStatsTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
public Properties hibernateProperties() {
    return new Properties() {
        {
            setProperty(org.hibernate.cfg.Environment.DIALECT, environment.getProperty(org.hibernate.cfg.Environment.DIALECT, HSQLDialect.class.getName()));
            setProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO, environment.getProperty(org.hibernate.cfg.Environment.HBM2DDL_AUTO));
            setProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, environment.getProperty(org.hibernate.cfg.Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true"));
        }
    };
}
 
Example #24
Source File: EnvironmentConfig.java    From blog with Apache License 2.0 5 votes vote down vote up
@Bean
@Qualifier("hibernateProperties")
public Properties hibernateProperties() {
	Properties properties = new Properties();
	properties.put("hibernate.dialect", HSQLDialect.class.getName());
	properties.put("hibernate.show_sql", "true");
	return properties;
}
 
Example #25
Source File: EnvironmentConfig.java    From blog with Apache License 2.0 5 votes vote down vote up
@Bean
@Qualifier("hibernateProperties")
public Properties hibernateProperties() {
	Properties properties = new Properties();
	properties.put("hibernate.dialect", HSQLDialect.class.getName());
	properties.put("hibernate.show_sql", "true");
	return properties;
}
 
Example #26
Source File: SaveMethodsIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeTests() {
    Configuration configuration = new Configuration().addAnnotatedClass(Person.class).setProperty("hibernate.dialect", HSQLDialect.class.getName()).setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
            .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test").setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "").setProperty("hibernate.hbm2ddl.auto", "update");
    ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
    sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
 
Example #27
Source File: ABCProxyTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testDiscriminatorFiltering() throws Exception {
	if ( ( getDialect() instanceof HSQLDialect ) ) return;
	Session s = openSession();
	Transaction t = s.beginTransaction();
	s.createQuery("from C1 c1 left join c1.c2s c2").list();
	s.createCriteria(C1.class).createCriteria("c2s").list();
	t.commit();
	s.close();
}
 
Example #28
Source File: RepositoryIOTest.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
public void testLoadSaveRepository() throws
		Exception {

	Class.forName("org.hsqldb.jdbc.JDBCDriver").newInstance();
	Connection theConnection = null;
	try {
		theConnection = DriverManager.getConnection("jdbc:hsqldb:mem:dname", "sa", "");

		Class theHibernateDialect = HSQLDialect.class;

		String theModelResource = "/de/erdesignerng/test/io/repository/examplemodel.mxm";

		String theNewFile = RepositioryHelper.performRepositorySaveAndLoad(theModelResource, theHibernateDialect,
				theConnection);

		String theOriginalFile = IOUtils.toString(getClass().getResourceAsStream(theModelResource));

		assertTrue(compareStrings(theOriginalFile, theNewFile));

	} finally {
		if (theConnection != null) {

			theConnection.createStatement().execute("SHUTDOWN");
			theConnection.close();
		}
	}
}
 
Example #29
Source File: DatabaseImplTest.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
private DatabaseImpl database() {
    DatabaseOptions options = new DatabaseOptions();
    options.url = "jdbc:hsqldb:mem:db;sql.syntax_mys=true";
    options.createTableEnabled = true;
    options.dialect = HSQLDialect.class.getName();
    options.driver = "org.hsqldb.jdbc.JDBCDriver";

    return new DatabaseImpl(options);
}
 
Example #30
Source File: FooBarTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testAutoFlush() throws Exception {
	Session s = openSession();
	Transaction txn = s.beginTransaction();
	FooProxy foo = new Foo();
	s.save(foo);
	assertTrue( "autoflush create", s.find("from Foo foo").size()==1 );
	foo.setChar( new Character('X') );
	assertTrue( "autoflush update", s.find("from Foo foo where foo.char='X'").size()==1 );
	txn.commit();
	s.close();

	s = openSession();
	txn = s.beginTransaction();
	foo = (FooProxy) s.load( Foo.class, foo.getKey() );
	//s.update( new Foo(), foo.getKey() );
	//assertTrue( s.find("from Foo foo where not foo.char='X'").size()==1, "autoflush update" );
	if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof HSQLDialect) && !(getDialect() instanceof PointbaseDialect) )  {
		foo.setBytes( "osama".getBytes() );
		assertTrue( "autoflush collection update", s.find("from Foo foo where 111 in elements(foo.bytes)").size()==1 );
		foo.getBytes()[0] = 69;
		assertTrue( "autoflush collection update", s.find("from Foo foo where 69 in elements(foo.bytes)").size()==1 );
	}
	s.delete(foo);
	assertTrue( "autoflush delete", s.find("from Foo foo").size()==0 );
	txn.commit();
	s.close();
}