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 '`';
|
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
|
@Override
|
||||||
public boolean supportsIfExistsBeforeTableName() {
|
public boolean supportsIfExistsBeforeTableName() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class PersistentMapTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
|
||||||
user = (User) s.get( User.class, 1 );
|
user = s.get( User.class, 1 );
|
||||||
user.userDatas.clear();
|
user.userDatas.clear();
|
||||||
s.update( user );
|
s.update( user );
|
||||||
Query q = s.createQuery( "DELETE FROM " + UserData.class.getName() + " d WHERE d.user = :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();
|
q.executeUpdate();
|
||||||
|
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.clear();
|
|
||||||
|
s.getTransaction().begin();
|
||||||
assertEquals( ( (User) s.get( User.class, user.id ) ).userDatas.size(), 0 );
|
|
||||||
|
assertEquals( s.get( User.class, user.id ).userDatas.size(), 0 );
|
||||||
assertEquals( s.createQuery( "FROM " + UserData.class.getName() ).list().size(), 0 );
|
assertEquals( s.createQuery( "FROM " + UserData.class.getName() ).list().size(), 0 );
|
||||||
|
s.createQuery( "delete " + User.class.getName() ).executeUpdate();
|
||||||
|
|
||||||
|
s.getTransaction().commit();
|
||||||
s.close();
|
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]
|
// ...al0_7_.mammal where [abs(cast(1 as float(19))-cast(? as float(19)))=1.0]
|
||||||
return;
|
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");
|
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;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "entity1")
|
@Table(name = "child")
|
||||||
public class Child {
|
public class Child {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
|
|
@ -24,15 +24,12 @@
|
||||||
package org.hibernate.test.hql.fetchAndJoin;
|
package org.hibernate.test.hql.fetchAndJoin;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "entity1")
|
@Table(name = "grandchild")
|
||||||
public class GrandChild {
|
public class GrandChild {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
|
|
@ -35,7 +35,7 @@ import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "entity1")
|
@Table(name = "parent")
|
||||||
public class Parent {
|
public class Parent {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
|
||||||
|
@ -73,6 +75,8 @@ public class ToManyFetchAndJoinTest extends BaseCoreFunctionalTestCase {
|
||||||
public void cleanupData() {
|
public void cleanupData() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
s.createQuery( "delete GrandChild" ).executeUpdate();
|
||||||
|
s.createQuery( "delete Child" ).executeUpdate();
|
||||||
s.createQuery( "delete Parent" ).executeUpdate();
|
s.createQuery( "delete Parent" ).executeUpdate();
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -23,28 +23,29 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.id;
|
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.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
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.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.jdbc.Work;
|
import org.hibernate.jdbc.Work;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ public class PooledHiLoSequenceIdentifierTest extends BaseCoreFunctionalTestCase
|
||||||
|
|
||||||
assertEquals( 7, countInsertedRows( s ) );
|
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 ) {
|
for ( Number id : ids ) {
|
||||||
log.debug( "Found id: " + id );
|
log.debug( "Found id: " + id );
|
||||||
}
|
}
|
||||||
|
@ -128,16 +129,18 @@ public class PooledHiLoSequenceIdentifierTest extends BaseCoreFunctionalTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertNewRow(Session session) {
|
private void insertNewRow(Session session) {
|
||||||
|
final SessionImplementor si = (SessionImplementor) session;
|
||||||
|
final SessionFactoryImplementor sfi = si.getFactory();
|
||||||
|
|
||||||
session.doWork(
|
session.doWork(
|
||||||
new Work() {
|
new Work() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Connection connection) throws SQLException {
|
public void execute(Connection connection) throws SQLException {
|
||||||
Statement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = connection.createStatement();
|
statement = connection.prepareStatement( "INSERT INTO sequenceIdentifier VALUES (?)" );
|
||||||
statement.executeUpdate(
|
statement.setObject( 1, sfi.getIdentifierGenerator( SequenceIdentifier.class.getName() ).generate( si, null ) );
|
||||||
"INSERT INTO sequenceIdentifier VALUES (NEXT VALUE FOR hibernate_sequence)"
|
statement.executeUpdate();
|
||||||
);
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( statement != null ) {
|
if ( statement != null ) {
|
||||||
|
|
|
@ -2947,11 +2947,17 @@ public class FooBarTest extends LegacyTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
s.load( bar, bar.getKey() );
|
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( "collection contains self", bar.getAbstracts().size() == 2 && bar.getAbstracts().contains( bar ) );
|
||||||
assertTrue( "association to self", bar.getFoo()==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.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,24 +39,24 @@ public class MapTest extends LegacyTestCase {
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("$type$", "TestMap");
|
map.put("$type$", "TestMap");
|
||||||
map.put("name", "foo");
|
map.put( "name", "foo" );
|
||||||
map.put("address", "bar");
|
map.put( "address", "bar" );
|
||||||
Map cmp = new HashMap();
|
Map cmp = new HashMap();
|
||||||
cmp.put( "a", new Integer(1) );
|
cmp.put( "a", new Integer( 1 ) );
|
||||||
cmp.put( "b", new Float(1.0) );
|
cmp.put( "b", new Float( 1.0 ) );
|
||||||
map.put("cmp", cmp);
|
map.put( "cmp", cmp );
|
||||||
s.save(map);
|
s.save( map );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
map = (Map) s.get( "TestMap", (Serializable) map.get("id") );
|
map = (Map) s.get( "TestMap", (Serializable) map.get("id") );
|
||||||
assertTrue( map!=null && "foo".equals( map.get("name") ) );
|
assertTrue( map != null && "foo".equals( map.get( "name" ) ) );
|
||||||
assertTrue( map.get("$type$").equals("TestMap") );
|
assertTrue( map.get( "$type$" ).equals( "TestMap" ) );
|
||||||
|
|
||||||
int size = s.createCriteria("TestMap").add( Example.create(map) ).list().size();
|
int size = s.createCriteria("TestMap").add( Example.create(map) ).list().size();
|
||||||
assertTrue(size==1);
|
assertTrue( size == 1 );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
|
@ -67,12 +67,12 @@ public class MapTest extends LegacyTestCase {
|
||||||
assertTrue( "foo".equals( map.get("name") ) );
|
assertTrue( "foo".equals( map.get("name") ) );
|
||||||
assertTrue( "bar".equals( map.get("address") ) );
|
assertTrue( "bar".equals( map.get("address") ) );
|
||||||
cmp = (Map) map.get("cmp");
|
cmp = (Map) map.get("cmp");
|
||||||
assertTrue( new Integer(1).equals( cmp.get("a") ) && new Float(1.0).equals( cmp.get("b") ) );
|
assertTrue( new Integer( 1 ).equals( cmp.get( "a" ) ) && new Float( 1.0 ).equals( cmp.get( "b" ) ) );
|
||||||
assertTrue( null==map.get("parent") );
|
assertTrue( null == map.get( "parent" ) );
|
||||||
map.put("name", "foobar");
|
map.put( "name", "foobar" );
|
||||||
map.put("parent", map);
|
map.put( "parent", map );
|
||||||
List bag = (List) map.get("children");
|
List bag = (List) map.get("children");
|
||||||
bag.add(map);
|
bag.add( map );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
|
@ -92,8 +92,12 @@ public class MapTest extends LegacyTestCase {
|
||||||
.add( Restrictions.eq("name", "foobar") )
|
.add( Restrictions.eq("name", "foobar") )
|
||||||
.list()
|
.list()
|
||||||
.size();
|
.size();
|
||||||
assertTrue(size==1);
|
assertTrue( size == 1 );
|
||||||
|
|
||||||
|
// for MySQL :(
|
||||||
|
map.put( "parent", null );
|
||||||
|
map.put( "children", null );
|
||||||
|
s.flush();
|
||||||
s.delete(map);
|
s.delete(map);
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -196,12 +196,16 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
s.save(m);
|
s.save(m);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
t = s.beginTransaction();
|
t = s.beginTransaction();
|
||||||
Iterator i = s.createQuery( "from Master" ).iterate();
|
Iterator i = s.createQuery( "from Master" ).iterate();
|
||||||
m = (Master) i.next();
|
m = (Master) i.next();
|
||||||
assertTrue( m.getOtherMaster()==m );
|
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);
|
s.delete(m);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
@ -243,8 +247,11 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
m2 = (Master) s.createCriteria(Master.class)
|
m2 = (Master) s.createCriteria(Master.class)
|
||||||
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
.add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
assertTrue( null==m2 );
|
assertTrue( null == m2 );
|
||||||
if (getDialect() instanceof HSQLDialect) { m1.setOtherMaster(null); s.flush(); }
|
if (getDialect() instanceof HSQLDialect || getDialect() instanceof MySQLDialect) {
|
||||||
|
m1.setOtherMaster(null);
|
||||||
|
s.flush();
|
||||||
|
}
|
||||||
s.delete(m1);
|
s.delete(m1);
|
||||||
t.commit();
|
t.commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -39,7 +39,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||||
assertNull( entity.getLongByteArray() );
|
assertNull( entity.getLongByteArray() );
|
||||||
entity.setLongByteArray( original );
|
entity.setLongByteArray( original );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
|
@ -47,7 +47,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||||
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
|
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
|
||||||
assertEquals( original, entity.getLongByteArray() );
|
assertEquals( original, entity.getLongByteArray() );
|
||||||
entity.setLongByteArray( changed );
|
entity.setLongByteArray( changed );
|
||||||
|
@ -56,7 +56,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||||
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
|
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
|
||||||
assertEquals( changed, entity.getLongByteArray() );
|
assertEquals( changed, entity.getLongByteArray() );
|
||||||
entity.setLongByteArray( null );
|
entity.setLongByteArray( null );
|
||||||
|
@ -65,7 +65,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||||
assertNull( entity.getLongByteArray() );
|
assertNull( entity.getLongByteArray() );
|
||||||
entity.setLongByteArray( empty );
|
entity.setLongByteArray( empty );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
|
@ -73,7 +73,7 @@ public abstract class LongByteArrayTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
entity = ( LongByteArrayHolder ) s.get( LongByteArrayHolder.class, entity.getId() );
|
entity = s.get( LongByteArrayHolder.class, entity.getId() );
|
||||||
if ( entity.getLongByteArray() != null ) {
|
if ( entity.getLongByteArray() != null ) {
|
||||||
Assert.assertEquals( empty.length, entity.getLongByteArray().length );
|
Assert.assertEquals( empty.length, entity.getLongByteArray().length );
|
||||||
assertEquals( empty, entity.getLongByteArray() );
|
assertEquals( empty, entity.getLongByteArray() );
|
||||||
|
|
Loading…
Reference in New Issue