HHH-9930 - Enable mariadb (mysql) database profile
This commit is contained in:
parent
c00d4609ef
commit
c154d7edf7
|
@ -277,6 +277,36 @@ public class MySQLDialect extends Dialect {
|
|||
return '`';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreateCatalog() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCreateCatalogCommand(String catalogName) {
|
||||
return new String[] { "create database " + catalogName };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDropCatalogCommand(String catalogName) {
|
||||
return new String[] { "drop database " + catalogName };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreateSchema() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCreateSchemaCommand(String schemaName) {
|
||||
throw new UnsupportedOperationException( "MySQL does not support dropping creating/dropping schemas in the JDBC sense" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDropSchemaCommand(String schemaName) {
|
||||
throw new UnsupportedOperationException( "MySQL does not support dropping creating/dropping schemas in the JDBC sense" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsIfExistsBeforeTableName() {
|
||||
return true;
|
||||
|
|
|
@ -177,7 +177,7 @@ public class PersistentMapTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s.beginTransaction();
|
||||
|
||||
user = (User) s.get( User.class, 1 );
|
||||
user = s.get( User.class, 1 );
|
||||
user.userDatas.clear();
|
||||
s.update( user );
|
||||
Query q = s.createQuery( "DELETE FROM " + UserData.class.getName() + " d WHERE d.user = :user" );
|
||||
|
@ -185,11 +185,14 @@ public class PersistentMapTest extends BaseCoreFunctionalTestCase {
|
|||
q.executeUpdate();
|
||||
|
||||
s.getTransaction().commit();
|
||||
s.clear();
|
||||
|
||||
assertEquals( ( (User) s.get( User.class, user.id ) ).userDatas.size(), 0 );
|
||||
|
||||
s.getTransaction().begin();
|
||||
|
||||
assertEquals( s.get( User.class, user.id ).userDatas.size(), 0 );
|
||||
assertEquals( s.createQuery( "FROM " + UserData.class.getName() ).list().size(), 0 );
|
||||
|
||||
s.createQuery( "delete " + User.class.getName() ).executeUpdate();
|
||||
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -348,6 +348,12 @@ public class HQLTest extends QueryTranslatorTestCase {
|
|||
// ...al0_7_.mammal where [abs(cast(1 as float(19))-cast(? as float(19)))=1.0]
|
||||
return;
|
||||
}
|
||||
if ( getDialect() instanceof MySQLDialect ) {
|
||||
// MySQL dialects are smarter now wrt cast targets. For example, float (as a db type) is not
|
||||
// valid as a cast target for MySQL. The new parser uses the dialect handling for casts, the old
|
||||
// parser does not; so the outputs do not match here...
|
||||
return;
|
||||
}
|
||||
assertTranslation("from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0");
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "entity1")
|
||||
@Table(name = "child")
|
||||
public class Child {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -24,15 +24,12 @@
|
|||
package org.hibernate.test.hql.fetchAndJoin;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "entity1")
|
||||
@Table(name = "grandchild")
|
||||
public class GrandChild {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -35,7 +35,7 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "entity1")
|
||||
@Table(name = "parent")
|
||||
public class Parent {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.dialect.MySQLDialect;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
|
@ -73,6 +75,8 @@ public class ToManyFetchAndJoinTest extends BaseCoreFunctionalTestCase {
|
|||
public void cleanupData() {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
s.createQuery( "delete GrandChild" ).executeUpdate();
|
||||
s.createQuery( "delete Child" ).executeUpdate();
|
||||
s.createQuery( "delete Parent" ).executeUpdate();
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
|
|
@ -23,28 +23,29 @@
|
|||
*/
|
||||
package org.hibernate.test.id;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.jdbc.Work;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -75,7 +76,7 @@ public class PooledHiLoSequenceIdentifierTest extends BaseCoreFunctionalTestCase
|
|||
|
||||
assertEquals( 7, countInsertedRows( s ) );
|
||||
|
||||
List<Number> ids = s.createSQLQuery( "SELECT id FROM sequenceIdentifier" ).list();
|
||||
List<Number> ids = s.createQuery( "SELECT id FROM sequenceIdentifier" ).list();
|
||||
for ( Number id : ids ) {
|
||||
log.debug( "Found id: " + id );
|
||||
}
|
||||
|
@ -128,16 +129,18 @@ public class PooledHiLoSequenceIdentifierTest extends BaseCoreFunctionalTestCase
|
|||
}
|
||||
|
||||
private void insertNewRow(Session session) {
|
||||
final SessionImplementor si = (SessionImplementor) session;
|
||||
final SessionFactoryImplementor sfi = si.getFactory();
|
||||
|
||||
session.doWork(
|
||||
new Work() {
|
||||
@Override
|
||||
public void execute(Connection connection) throws SQLException {
|
||||
Statement statement = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = connection.createStatement();
|
||||
statement.executeUpdate(
|
||||
"INSERT INTO sequenceIdentifier VALUES (NEXT VALUE FOR hibernate_sequence)"
|
||||
);
|
||||
statement = connection.prepareStatement( "INSERT INTO sequenceIdentifier VALUES (?)" );
|
||||
statement.setObject( 1, sfi.getIdentifierGenerator( SequenceIdentifier.class.getName() ).generate( si, null ) );
|
||||
statement.executeUpdate();
|
||||
}
|
||||
finally {
|
||||
if ( statement != null ) {
|
||||
|
|
|
@ -2947,11 +2947,17 @@ public class FooBarTest extends LegacyTestCase {
|
|||
s = openSession();
|
||||
s.beginTransaction();
|
||||
s.load( bar, bar.getKey() );
|
||||
bar2 = s.load( Bar.class, bar2.getKey() );
|
||||
assertTrue( "collection contains self", bar.getAbstracts().size() == 2 && bar.getAbstracts().contains( bar ) );
|
||||
assertTrue( "association to self", bar.getFoo()==bar );
|
||||
for ( Object o : bar.getAbstracts() ) {
|
||||
s.delete( o );
|
||||
}
|
||||
|
||||
// for MySQL :(
|
||||
bar.getAbstracts().clear();
|
||||
bar.setFoo( null );
|
||||
s.flush();
|
||||
|
||||
s.delete( bar );
|
||||
s.delete( bar2 );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -39,24 +39,24 @@ public class MapTest extends LegacyTestCase {
|
|||
s.beginTransaction();
|
||||
Map map = new HashMap();
|
||||
map.put("$type$", "TestMap");
|
||||
map.put("name", "foo");
|
||||
map.put("address", "bar");
|
||||
map.put( "name", "foo" );
|
||||
map.put( "address", "bar" );
|
||||
Map cmp = new HashMap();
|
||||
cmp.put( "a", new Integer(1) );
|
||||
cmp.put( "b", new Float(1.0) );
|
||||
map.put("cmp", cmp);
|
||||
s.save(map);
|
||||
cmp.put( "a", new Integer( 1 ) );
|
||||
cmp.put( "b", new Float( 1.0 ) );
|
||||
map.put( "cmp", cmp );
|
||||
s.save( map );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
map = (Map) s.get( "TestMap", (Serializable) map.get("id") );
|
||||
assertTrue( map!=null && "foo".equals( map.get("name") ) );
|
||||
assertTrue( map.get("$type$").equals("TestMap") );
|
||||
assertTrue( map != null && "foo".equals( map.get( "name" ) ) );
|
||||
assertTrue( map.get( "$type$" ).equals( "TestMap" ) );
|
||||
|
||||
int size = s.createCriteria("TestMap").add( Example.create(map) ).list().size();
|
||||
assertTrue(size==1);
|
||||
assertTrue( size == 1 );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
|
@ -67,12 +67,12 @@ public class MapTest extends LegacyTestCase {
|
|||
assertTrue( "foo".equals( map.get("name") ) );
|
||||
assertTrue( "bar".equals( map.get("address") ) );
|
||||
cmp = (Map) map.get("cmp");
|
||||
assertTrue( new Integer(1).equals( cmp.get("a") ) && new Float(1.0).equals( cmp.get("b") ) );
|
||||
assertTrue( null==map.get("parent") );
|
||||
map.put("name", "foobar");
|
||||
map.put("parent", map);
|
||||
assertTrue( new Integer( 1 ).equals( cmp.get( "a" ) ) && new Float( 1.0 ).equals( cmp.get( "b" ) ) );
|
||||
assertTrue( null == map.get( "parent" ) );
|
||||
map.put( "name", "foobar" );
|
||||
map.put( "parent", map );
|
||||
List bag = (List) map.get("children");
|
||||
bag.add(map);
|
||||
bag.add( map );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
|
@ -92,8 +92,12 @@ public class MapTest extends LegacyTestCase {
|
|||
.add( Restrictions.eq("name", "foobar") )
|
||||
.list()
|
||||
.size();
|
||||
assertTrue(size==1);
|
||||
assertTrue( size == 1 );
|
||||
|
||||
// for MySQL :(
|
||||
map.put( "parent", null );
|
||||
map.put( "children", null );
|
||||
s.flush();
|
||||
s.delete(map);
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
|
|
@ -196,12 +196,16 @@ public class MasterDetailTest extends LegacyTestCase {
|
|||
s.save(m);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
Iterator i = s.createQuery( "from Master" ).iterate();
|
||||
m = (Master) i.next();
|
||||
assertTrue( m.getOtherMaster()==m );
|
||||
if (getDialect() instanceof HSQLDialect) { m.setOtherMaster(null); s.flush(); }
|
||||
if ( getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect ) {
|
||||
m.setOtherMaster(null);
|
||||
s.flush();
|
||||
}
|
||||
s.delete(m);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
@ -243,8 +247,11 @@ public class MasterDetailTest extends LegacyTestCase {
|
|||
m2 = (Master) s.createCriteria(Master.class)
|
||||
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
||||
.uniqueResult();
|
||||
assertTrue( null==m2 );
|
||||
if (getDialect() instanceof HSQLDialect) { m1.setOtherMaster(null); s.flush(); }
|
||||
assertTrue( null == m2 );
|
||||
if (getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect) {
|
||||
m1.setOtherMaster(null);
|
||||
s.flush();
|
||||
}
|
||||
s.delete(m1);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
|
|
@ -39,7 +39,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
assertNull( entity.getLongByteArray() );
|
||||
entity.setLongByteArray( original );
|
||||
s.getTransaction().commit();
|
||||
|
@ -47,7 +47,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
|
||||
assertEquals( original, entity.getLongByteArray() );
|
||||
entity.setLongByteArray( changed );
|
||||
|
@ -56,7 +56,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
|
||||
assertEquals( changed, entity.getLongByteArray() );
|
||||
entity.setLongByteArray( null );
|
||||
|
@ -65,7 +65,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
assertNull( entity.getLongByteArray() );
|
||||
entity.setLongByteArray( empty );
|
||||
s.getTransaction().commit();
|
||||
|
@ -73,7 +73,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||
if ( entity.getLongByteArray() != null ) {
|
||||
Assert.assertEquals( empty.length, entity.getLongByteArray().length );
|
||||
assertEquals( empty, entity.getLongByteArray() );
|
||||
|
|
Loading…
Reference in New Issue