Compare commits

...
Author SHA1 Message Date
Rob Bygrave 4bd9e67703 [maven-release-plugin] prepare release ebean-11.10.4 2018-02-14 15:29:12 +13:00
Rob Bygrave 2a986ab590 #1260 - Mark query.setForUpdate(true) as deprecated - migrate to query.forUpdate() 2018-02-14 15:28:13 +13:00
Rob Bygrave 7c477827fe #1259 - Throw explicit mapping error when an Enum is mapped to both ORDINAL and STRING 2018-02-14 12:39:35 +13:00
Rob Bygrave b2967dec1e #1257 - ServerConfig with register = true, defaultServer = false ... fails as it tries to create the default server 2018-02-13 16:22:52 +13:00
Rob Bygrave a95fd063ae #1256 - Query where many isNotEmpty() ... on ManyToMany with SoftDelete produces incorrect SQL (Part 2) 2018-02-13 14:52:18 +13:00
Rob Bygrave 17a54e3804 No effective change - extra tests for DeployPropertyParser 2018-02-13 14:09:08 +13:00
Rob Bygrave f1b2a09b30 Testing - modify .travis to run mysql as service (bump MySql version to 5.7) 2018-02-10 01:16:40 +13:00
Rob Bygrave e4d9e4f2de Testing - modify .travis to run mysql as service (bump MySql version to 5.7) 2018-02-10 01:04:19 +13:00
Rob Bygrave 6474f306b5 #1255 - Regression on raw LIKE expression with slashes on Postgres
Related update for Sqlite
2018-02-10 00:57:19 +13:00
Rob Bygrave f1c2f134ad #1255 - Regression on raw LIKE expression with slashes on Postgres
Related update for Sqlite
2018-02-10 00:56:05 +13:00
Rob Bygrave 0f7158ea18 Testing - modify .travis to run mysql as service 2018-02-10 00:34:34 +13:00
Rob Bygrave 3fdb76d18f Testing - modify .travis to run mysql as service 2018-02-10 00:31:39 +13:00
Rob Bygrave b1027a2f25 Testing - modify .travis to run mysql as docker container 2018-02-10 00:18:33 +13:00
Rob Bygrave e5a1f9f7cc Testing - modify .travis adding docker service 2018-02-10 00:07:27 +13:00
Rob Bygrave f78f24136a [maven-release-plugin] prepare for next development iteration 2018-02-09 23:42:42 +13:00
24 changed files with 296 additions and 80 deletions
+11
View File
@@ -9,16 +9,27 @@ git:
addons:
postgresql: "9.6"
# apt:
# packages:
# - mysql-server-5.7
# - mysql-client-core-5.7
# - mysql-client-5.7
services:
- docker
- postgresql
- mysql
before_script:
- ./.travis/setup_database
- mysql -u root -e 'CREATE DATABASE test_ebean;'
- mysql -u root -e "CREATE USER 'test_ebean'@'localhost' IDENTIFIED BY 'test';"
- mysql -u root -e "GRANT ALL ON test_ebean.* TO 'test_ebean'@'localhost';"
env:
- EBEAN_DB=h2
- EBEAN_DB=pg
# - EBEAN_DB=mysql
install: true
+2 -2
View File
@@ -9,7 +9,7 @@
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>11.10.3</version>
<version>11.10.4</version>
<packaging>jar</packaging>
<name>ebean</name>
@@ -17,7 +17,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-11.10.3</tag>
<tag>ebean-11.10.4</tag>
</scm>
<profiles>
+3 -11
View File
@@ -5,10 +5,10 @@ import io.ebean.cache.ServerCacheManager;
import io.ebean.config.ServerConfig;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
import java.util.Collection;
@@ -131,8 +131,7 @@ public final class Ebean {
private final ConcurrentHashMap<String, EbeanServer> concMap = new ConcurrentHashMap<>();
/**
* Cache for synchronized read, creation and put. Protected by the monitor
* object.
* Cache for synchronized read, creation and put. Protected by the monitor object.
*/
private final HashMap<String, EbeanServer> syncMap = new HashMap<>();
@@ -146,14 +145,7 @@ public final class Ebean {
private ServerManager() {
try {
// skipDefaultServer is set by EbeanServerFactory
// ... when it is creating the primaryServer
if (PrimaryServer.isSkip()) {
// primary server being created by EbeanServerFactory
// ... so we should not try and create it here
logger.debug("PrimaryServer.isSkip()");
} else {
if (!PrimaryServer.isSkip()) {
// look to see if there is a default server defined
String defaultName = PrimaryServer.getDefaultServerName();
logger.debug("defaultName:{}", defaultName);
@@ -65,10 +65,8 @@ public class EbeanServerFactory {
EbeanServer server = createInternal(config);
if (config.isDefaultServer()) {
PrimaryServer.setSkip(true);
}
if (config.isRegister()) {
PrimaryServer.setSkip(true);
Ebean.register(server, config.isDefaultServer());
}
+3
View File
@@ -1436,9 +1436,12 @@ public interface Query<T> {
String getGeneratedSql();
/**
* Deprecated - migrate to forUpdate().
*
* executed the select with "for update" which should lock the record
* "on read"
*/
@Deprecated
Query<T> setForUpdate(boolean forUpdate);
/**
@@ -19,12 +19,17 @@ public class SQLitePlatform extends DatabasePlatform {
this.dbIdentity.setSelectLastInsertedIdTemplate("select last_insert_rowid()");
this.booleanDbType = Types.INTEGER;
this.likeClauseRaw = "like ?";
this.likeClauseEscaped = "like ?";
dbTypeMap.put(DbType.BIT, new DbPlatformType("int default 0"));
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("int default 0"));
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("integer"));
dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("integer"));
}
protected void escapeLikeCharacter(char ch, StringBuilder sb) {
sb.append(ch);
}
}
@@ -331,6 +331,7 @@ public class DefaultContainer implements SpiContainer {
dsConfig.setAutoCommit(true);
//dsConfig.setReadOnly(true);
dsConfig.setDefaults(config.getDataSourceConfig());
dsConfig.setIsolationLevel(config.getDataSourceConfig().getIsolationLevel());
}
String poolName = config.getName() + (readOnly ? "-ro" : "");
return factory.createPool(poolName, dsConfig);
@@ -37,6 +37,8 @@ public abstract class DeployParser {
protected int pos;
protected String priorWord;
protected String word;
protected char wordTerminator;
@@ -45,7 +47,6 @@ public abstract class DeployParser {
public abstract String getDeployWord(String expression);
/**
* Return the join includes.
*/
@@ -67,8 +68,14 @@ public abstract class DeployParser {
this.sb = new StringBuilder(source.length() + 20);
while (nextWord()) {
String deployWord = convertWord();
sb.append(deployWord);
if (skipWordConvert()) {
sb.append(word);
priorWord = word;
} else {
String deployWord = convertWord();
sb.append(deployWord);
priorWord = deployWord;
}
if (pos < sourceLength) {
sb.append(wordTerminator);
if (wordTerminator == SINGLE_QUOTE) {
@@ -80,6 +87,10 @@ public abstract class DeployParser {
return sb.toString();
}
protected boolean skipWordConvert() {
return false;
}
private boolean nextWord() {
if (!findWordStart()) {
@@ -14,12 +14,15 @@ import java.util.Set;
*/
public final class DeployPropertyParser extends DeployParser {
private static final String JOIN = "join";
private static final String FROM = "from";
private final BeanDescriptor<?> beanDescriptor;
private final Set<String> includes = new HashSet<>();
public DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
this.beanDescriptor = beanDescriptor;
}
@@ -28,6 +31,13 @@ public final class DeployPropertyParser extends DeployParser {
return includes;
}
/**
* Skip if in raw sql expression with from tableName or join tableName.
*/
protected boolean skipWordConvert() {
return FROM.equalsIgnoreCase(priorWord) || JOIN.equalsIgnoreCase(priorWord);
}
@Override
public String getDeployWord(String expression) {
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
@@ -112,30 +112,16 @@ public class DeployUtil {
if (!enumType.isEnum()) {
throw new IllegalArgumentException("Class [" + enumType + "] is Not a Enum?");
}
ScalarType<?> scalarType = typeManager.getScalarType(enumType);
if (enumOverrideDefaultMapping(enumerated, scalarType)) {
logger.debug("override default enum mapping for type {}", enumType);
scalarType = null;
}
if (scalarType == null) {
// look for @DbEnumValue or @EnumValue annotations etc
Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) enumType;
EnumType type = enumerated != null ? enumerated.value() : null;
scalarType = typeManager.createEnumScalarType(enumClass, type);
}
prop.setScalarType(scalarType);
prop.setDbType(scalarType.getJdbcType());
}
try {
Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) enumType;
EnumType type = enumerated != null ? enumerated.value() : null;
ScalarType<?> scalarType = typeManager.createEnumScalarType(enumClass, type);
prop.setScalarType(scalarType);
prop.setDbType(scalarType.getJdbcType());
/**
* Return true if there is an existing default mapping for the enum that needs
* to be overridden (for example, DayOfWeek defaults to Integer mapping 1 to 7
* and some might want this mapped to 'MONDAY' etc).
*/
private boolean enumOverrideDefaultMapping(Enumerated enumerated, ScalarType<?> scalarType) {
return enumerated != null && scalarType != null
&& enumerated.value() == EnumType.STRING
&& scalarType.getJdbcType() != Types.VARCHAR;
} catch (IllegalStateException e) {
throw new PersistenceException("Error mapping property " + prop.getFullBeanName() + " - " + e.getMessage());
}
}
/**
@@ -304,7 +290,7 @@ public class DeployUtil {
prop.setScalarType(scalarType);
}
public boolean isClobType(Class<?> type) {
private boolean isClobType(Class<?> type) {
return type.equals(String.class);
}
@@ -1,6 +1,5 @@
package io.ebeaninternal.server.query;
import io.ebeaninternal.server.rawsql.SpiRawSql;
import io.ebeaninternal.api.BindParams;
import io.ebeaninternal.api.SpiExpressionList;
import io.ebeaninternal.api.SpiQuery;
@@ -12,6 +11,7 @@ import io.ebeaninternal.server.expression.DefaultExpressionRequest;
import io.ebeaninternal.server.persist.Binder;
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
import io.ebeaninternal.server.querydefn.OrmUpdateProperties;
import io.ebeaninternal.server.rawsql.SpiRawSql;
import io.ebeaninternal.server.type.DataBind;
import io.ebeaninternal.server.util.BindParamsParser;
import org.slf4j.Logger;
@@ -318,15 +318,9 @@ public class CQueryPredicates {
}
private String parse(String expr, DeployParser deployParser) {
StringBuilder sb = new StringBuilder();
if (!isEmpty(expr)) {
if (sb.length() > 0) {
sb.append(" and ");
}
sb.append(deployParser.parse(expr));
}
return sb.toString();
if (expr == null) return "";
if (expr.isEmpty()) return expr;
return deployParser.parse(expr);
}
private String deriveHaving(DeployParser deployParser) {
@@ -271,6 +271,7 @@ public final class DefaultTypeManager implements TypeManager {
public void addEnumType(ScalarType<?> scalarType, Class<? extends Enum> enumClass) {
Set<Class<?>> mappedClasses = new HashSet<>();
mappedClasses.add(enumClass);
for (Object value : EnumSet.allOf(enumClass).toArray()) {
mappedClasses.add(value.getClass());
}
@@ -552,7 +553,7 @@ public final class DefaultTypeManager implements TypeManager {
* Return null if the EnumValue annotations are not present/used.
* </p>
*/
private ScalarType<?> createEnumScalarType2(Class<?> enumType) {
private ScalarTypeEnum<?> createEnumScalarType2(Class<?> enumType) {
boolean integerType = true;
@@ -589,8 +590,11 @@ public final class DefaultTypeManager implements TypeManager {
@Override
public ScalarType<?> createEnumScalarType(Class<? extends Enum<?>> enumType, EnumType type) {
ScalarType<?> scalarType = getScalarType(enumType);
if (scalarType != null) {
ScalarTypeEnum<?> scalarType = (ScalarTypeEnum<?>) getScalarType(enumType);
if (scalarType != null && !scalarType.isOverrideBy(type)) {
if (type != null && !scalarType.isCompatible(type)) {
throw new IllegalStateException("Error mapping Enum type:"+enumType+" It is mapped using 2 different modes when only one is supported (ORDINAL, STRING or an Ebean mapping)");
}
return scalarType;
}
@@ -603,7 +607,7 @@ public final class DefaultTypeManager implements TypeManager {
return scalarType;
}
private ScalarType<?> createEnumScalarTypePerSpec(Class<?> enumType, EnumType type) {
private ScalarTypeEnum<?> createEnumScalarTypePerSpec(Class<?> enumType, EnumType type) {
if (type == null) {
// default as per spec is ORDINAL
return new ScalarTypeEnumStandard.OrdinalEnum(enumType);
@@ -616,7 +620,7 @@ public final class DefaultTypeManager implements TypeManager {
}
}
private ScalarType<?> createEnumScalarTypePerExtentions(Class<? extends Enum<?>> enumType) {
private ScalarTypeEnum<?> createEnumScalarTypePerExtentions(Class<? extends Enum<?>> enumType) {
Method[] methods = enumType.getMethods();
for (Method method : methods) {
@@ -638,7 +642,7 @@ public final class DefaultTypeManager implements TypeManager {
* Return null if the EnumValue annotations are not present/used.
* </p>
*/
private ScalarType<?> createEnumScalarTypeDbValue(Class<? extends Enum<?>> enumType, Method method, boolean integerType) {
private ScalarTypeEnum<?> createEnumScalarTypeDbValue(Class<? extends Enum<?>> enumType, Method method, boolean integerType) {
Map<String, String> nameValueMap = new HashMap<>();
@@ -664,7 +668,7 @@ public final class DefaultTypeManager implements TypeManager {
* length create the ScalarType for the Enum.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private ScalarType<?> createEnumScalarType(Class enumType, Map<String, String> nameValueMap, boolean integerType, int dbColumnLength) {
private ScalarTypeEnum<?> createEnumScalarType(Class enumType, Map<String, String> nameValueMap, boolean integerType, int dbColumnLength) {
EnumToDbValueMap<?> beanDbMap = EnumToDbValueMap.create(integerType);
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.sql.Types;
import java.time.DayOfWeek;
@@ -22,6 +23,14 @@ public class ScalarTypeDayOfWeek extends ScalarTypeEnumWithMapping {
super(beanDbMap, DayOfWeek.class, 1);
}
/**
* We allow this to be overridden by a JPA EnumType.
*/
@Override
public boolean isOverrideBy(EnumType type) {
return type != null;
}
/**
* Bind DayOfWeek enum using getValue().
*/
@@ -1,15 +1,29 @@
package io.ebeaninternal.server.type;
import javax.persistence.EnumType;
import java.util.Set;
/**
* Marker interface for the Enum scalar types.
*/
public interface ScalarTypeEnum {
public interface ScalarTypeEnum<T> extends ScalarType<T> {
/**
* Return the IN values for DB constraint construction.
*/
Set<String> getDbCheckConstraintValues();
/**
* Return true if we allow this scalar enum type to be overridden.
* Ability to override the built-in support for java time DayOfWeek and Month.
*/
default boolean isOverrideBy(EnumType type) {
return false;
}
/**
* Return true if the scalar type is compatible with the specified enum type.
*/
boolean isCompatible(EnumType enumType);
}
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonParser;
import io.ebean.text.TextException;
import io.ebeanservice.docstore.api.mapping.DocPropertyType;
import javax.persistence.EnumType;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -40,6 +41,11 @@ public class ScalarTypeEnumStandard {
this.length = maxValueLength(enumType);
}
@Override
public boolean isCompatible(EnumType enumType) {
return EnumType.STRING == enumType;
}
/**
* Return the IN values for DB constraint construction.
*/
@@ -128,6 +134,11 @@ public class ScalarTypeEnumStandard {
this.enumArray = EnumSet.allOf(enumType).toArray();
}
@Override
public boolean isCompatible(EnumType enumType) {
return EnumType.ORDINAL == enumType;
}
/**
* Return the IN values for DB constraint construction.
*/
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -24,6 +25,11 @@ public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase i
this.length = length;
}
@Override
public boolean isCompatible(EnumType enumType) {
return enumType == null;
}
@Override
public long asVersion(Object value) {
throw new RuntimeException("not supported");
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.sql.Types;
import java.time.Month;
@@ -22,6 +23,14 @@ public class ScalarTypeMonth extends ScalarTypeEnumWithMapping {
super(beanDbMap, Month.class, 1);
}
/**
* We allow this to be overridden by a JPA EnumType.
*/
@Override
public boolean isOverrideBy(EnumType type) {
return type != null;
}
/**
* Bind Month enum value.
*/
@@ -14,7 +14,7 @@ public class PrimaryServerTest extends BaseTestCase {
@Test
public void testIsSkipPrimaryServer() throws Exception {
public void testIsSkipPrimaryServer() {
PrimaryServer.setSkip(true);
assertTrue(PrimaryServer.isSkip());
PrimaryServer.setSkip(false);
@@ -23,14 +23,14 @@ public class PrimaryServerTest extends BaseTestCase {
@Test
@ForPlatform(Platform.H2)
public void testGetPrimaryServerName() throws Exception {
public void testGetPrimaryServerName() {
String primaryServerName = PrimaryServer.getDefaultServerName();
assertEquals("h2", primaryServerName);
}
@Test
public void testLoadProperties() throws Exception {
public void testLoadProperties() {
Properties properties = PrimaryServer.getProperties();
assertTrue(!properties.isEmpty());
@@ -12,10 +12,12 @@ import org.junit.Test;
import org.tests.model.ivo.Money;
import org.tests.model.ivo.converter.MoneyTypeConverter;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.sql.Types;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
public class TestTypeManager extends BaseTestCase {
@@ -42,6 +44,13 @@ public class TestTypeManager extends BaseTestCase {
assertThat(typeA).isNotNull();
ScalarType<?> typeC = typeManager.getScalarType(MyEnum.Cval.getClass());
assertThat(typeC).isNotNull();
try {
typeManager.createEnumScalarType(MyEnum.class, EnumType.STRING);
assertTrue("never get here",false);
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported");
}
}
@Test
@@ -65,6 +74,13 @@ public class TestTypeManager extends BaseTestCase {
val = dayOfWeekType.read(new DummyDataReader("FRIDAY "));
assertThat(val).isEqualTo(MyDayOfWeek.FRIDAY);
try {
typeManager.createEnumScalarType(MyDayOfWeek.class, EnumType.ORDINAL);
assertTrue("never get here",false);
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported");
}
}
@Test
@@ -73,8 +89,8 @@ public class TestTypeManager extends BaseTestCase {
DefaultTypeManager typeManager = createTypeManager();
ScalarType<?> scalarType = typeManager.getScalarType(Money.class);
Assert.assertTrue(scalarType.getJdbcType() == Types.DECIMAL);
Assert.assertTrue(!scalarType.isJdbcNative());
assertTrue(scalarType.getJdbcType() == Types.DECIMAL);
assertTrue(!scalarType.isJdbcNative());
Assert.assertEquals(Money.class, scalarType.getType());
}
@@ -0,0 +1,43 @@
package io.ebeaninternal.server.deploy;
import io.ebean.BaseTestCase;
import org.junit.Test;
import org.tests.model.basic.Customer;
import static org.assertj.core.api.Assertions.assertThat;
public class DeployPropertyParserTest extends BaseTestCase {
private final BeanDescriptor<Customer> descriptor = getBeanDescriptor(Customer.class);
@Test
public void from_prefix_expect_unchanged() {
assertThat(parser().parse("(select x from status join status)")).isEqualTo("(select x from status join status)");
}
@Test
public void depth0_path() {
assertThat(parser().parse("pre status post")).isEqualTo("pre ${}status post");
}
@Test
public void depth1_path() {
assertThat(parser().parse("billingAddress.city")).isEqualTo("${billingAddress}city");
}
@Test
public void depth2_path() {
assertThat(parser().parse("max(billingAddress.country.name)")).isEqualTo("max(${billingAddress.country}name)");
}
@Test
public void unknown_path() {
assertThat(parser().parse(" foo ")).isEqualTo(" foo ");
}
private DeployPropertyParser parser() {
return descriptor.createDeployPropertyParser();
}
}
@@ -5,23 +5,28 @@ import io.ebean.config.dbplatform.postgres.PostgresPlatform;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import org.junit.Test;
import javax.persistence.EnumType;
import java.time.DayOfWeek;
import java.time.Month;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class DefaultTypeManagerTest {
DefaultTypeManager typeManager;
public DefaultTypeManagerTest() {
private DefaultTypeManager create() {
ServerConfig serverConfig = new ServerConfig();
serverConfig.setDatabasePlatform(new PostgresPlatform());
BootupClasses bootupClasses = new BootupClasses();
typeManager = new DefaultTypeManager(serverConfig, bootupClasses);
return new DefaultTypeManager(serverConfig, bootupClasses);
}
@Test
public void isIntegerType() {
DefaultTypeManager typeManager = create();
assertTrue(typeManager.isIntegerType("1"));
assertTrue(typeManager.isIntegerType("0"));
@@ -33,4 +38,82 @@ public class DefaultTypeManagerTest {
assertFalse(typeManager.isIntegerType(" A"));
}
@Test
public void enumDayMonth_builtIn_overrideAsString() {
DefaultTypeManager typeManager = create();
ScalarType<?> type = typeManager.createEnumScalarType(Month.class, null);
assertThat(type).isInstanceOf(ScalarTypeEnumWithMapping.class).as("built in type");
// mapped explicitly as JPA EnumType.STRING
type = typeManager.createEnumScalarType(Month.class, EnumType.STRING);
assertThat(type).isInstanceOf(ScalarTypeEnumStandard.StringEnum.class).as("override built in type");
try {
typeManager.createEnumScalarType(Month.class, EnumType.ORDINAL);
assertThat(true).isFalse().as("never get here");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported");
}
}
@Test
public void enumMonth_builtIn_overrideAsOrdinal() {
DefaultTypeManager typeManager = create();
// mapped explicitly as JPA EnumType.STRING
ScalarType<?> type = typeManager.createEnumScalarType(Month.class, EnumType.ORDINAL);
assertThat(type).isInstanceOf(ScalarTypeEnumStandard.OrdinalEnum.class).as("override built in type");
try {
typeManager.createEnumScalarType(Month.class, EnumType.STRING);
assertThat(true).isFalse().as("never get here");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported");
}
}
@Test
public void enumDayOfWeek_builtIn_overrideAsString() {
DefaultTypeManager typeManager = create();
ScalarType<?> type = typeManager.createEnumScalarType(DayOfWeek.class, null);
assertThat(type).isInstanceOf(ScalarTypeEnumWithMapping.class).as("built in type");
// mapped explicitly as JPA EnumType.STRING
type = typeManager.createEnumScalarType(DayOfWeek.class, EnumType.STRING);
assertThat(type).isInstanceOf(ScalarTypeEnumStandard.StringEnum.class).as("override built in type");
try {
typeManager.createEnumScalarType(DayOfWeek.class, EnumType.ORDINAL);
assertThat(true).isFalse().as("never get here");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported");
}
}
@Test
public void enumDayOfWeek_builtIn_overrideAsOrdinal() {
DefaultTypeManager typeManager = create();
// mapped explicitly as JPA EnumType.STRING
ScalarType<?> type = typeManager.createEnumScalarType(DayOfWeek.class, EnumType.ORDINAL);
assertThat(type).isInstanceOf(ScalarTypeEnumStandard.OrdinalEnum.class).as("override built in type");
try {
typeManager.createEnumScalarType(DayOfWeek.class, EnumType.STRING);
assertThat(true).isFalse().as("never get here");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported");
}
}
}
@@ -18,6 +18,16 @@ public class MsManyA {
@SoftDelete
boolean deleted;
/**
* Name clash with M2M intersection table name.
*/
boolean ms_many_a_many_b;
/**
* Name clash with other side table name.
*/
boolean ms_many_b;
@ManyToMany
List<MsManyB> manybs;
+6 -2
View File
@@ -1,4 +1,10 @@
#mysql.version=5.7
#mysql.dbName=test_ebean
#mysql.dbUser=test_ebean
#mysql.dbPassword=test
#mysql.startMode=dropcreate
#sqlserver.version=2017-CU2
#sqlserver.port=1433
#sqlserver.dbName=test_ebean
@@ -11,8 +17,6 @@
#oracle.dbPassword=test
##oracle.startMode=dropcreate
#mysql.version=5.7
#mysql.startMode=dropcreate
#postgres.version=9.6
##postgres.dbName=test_db
+3 -7
View File
@@ -94,8 +94,6 @@ datasource.sqlite.password=
datasource.sqlite.databaseUrl=jdbc:sqlite:mydb.db
datasource.sqlite.databaseDriver=org.sqlite.JDBC
datasource.sqlite.isolationlevel=read_uncommitted
datasource.sqlite.minConnections=1
datasource.sqlite.maxConnections=25
datasource.hsqldb.username=sa
datasource.hsqldb.password=
@@ -103,11 +101,9 @@ datasource.hsqldb.databaseUrl=jdbc:hsqldb:mem:tests
datasource.hsqldb.databaseDriver=org.hsqldb.jdbcDriver
datasource.mysql.username=unit
datasource.mysql.password=unit
datasource.mysql.databaseUrl=jdbc:mysql://127.0.0.1:3306/unit
#connection String for Connector/j 6.0
#datasource.mysql.databaseUrl=jdbc:mysql://127.0.0.1:3306/unit?useLegacyDatetimeCode=false&serverTimezone=UTC
datasource.mysql.username=test_ebean
datasource.mysql.password=test
datasource.mysql.databaseUrl=jdbc:mysql://127.0.0.1:3306/test_ebean
datasource.mysql.databaseDriver=com.mysql.jdbc.Driver