mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2124 - ENH: Add name() attribute to @DbArray, @DbJson, @DbJsonB, @DbMap
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-annotation</artifactId>
|
||||
<version>6.14-SNAPSHOT</version>
|
||||
<version>6.15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -311,19 +311,23 @@ public class AnnotationFields extends AnnotationParser {
|
||||
DbMap dbMap = get(prop, DbMap.class);
|
||||
if (dbMap != null) {
|
||||
util.setDbMap(prop, dbMap);
|
||||
setColumnName(prop, dbMap.name());
|
||||
}
|
||||
DbJson dbJson = get(prop, DbJson.class);
|
||||
if (dbJson != null) {
|
||||
util.setDbJsonType(prop, dbJson);
|
||||
setColumnName(prop, dbJson.name());
|
||||
} else {
|
||||
DbJsonB dbJsonB = get(prop, DbJsonB.class);
|
||||
if (dbJsonB != null) {
|
||||
util.setDbJsonBType(prop, dbJsonB);
|
||||
setColumnName(prop, dbJsonB.name());
|
||||
}
|
||||
}
|
||||
DbArray dbArray = get(prop, DbArray.class);
|
||||
if (dbArray != null) {
|
||||
util.setDbArray(prop, dbArray);
|
||||
setColumnName(prop, dbArray.name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,11 +99,7 @@ public abstract class AnnotationParser extends AnnotationBase {
|
||||
}
|
||||
|
||||
void readColumn(Column columnAnn, DeployBeanProperty prop) {
|
||||
|
||||
if (!isEmpty(columnAnn.name())) {
|
||||
prop.setDbColumn(databasePlatform.convertQuotedIdentifiers(columnAnn.name()));
|
||||
}
|
||||
|
||||
setColumnName(prop, columnAnn.name());
|
||||
prop.setDbInsertable(columnAnn.insertable());
|
||||
prop.setDbUpdateable(columnAnn.updatable());
|
||||
prop.setNullable(columnAnn.nullable());
|
||||
@@ -125,6 +121,12 @@ public abstract class AnnotationParser extends AnnotationBase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setColumnName(DeployBeanProperty prop, String name) {
|
||||
if (!isEmpty(name)) {
|
||||
prop.setDbColumn(databasePlatform.convertQuotedIdentifiers(name));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the validation groups are {@link Default} (respectively empty)
|
||||
* can be applied to DDL generation.
|
||||
|
||||
@@ -71,6 +71,6 @@ public class TestDbJson_Jackson3 extends BaseTestCase {
|
||||
|
||||
final List<String> sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("update ebasic_json_list set name=?, bean_set=?, bean_list=?, plain_bean=?, version=? where id=?");
|
||||
assertThat(sql.get(0)).contains("update ebasic_json_list set name=?, beans=?, bean_list=?, plain_bean=?, version=? where id=?");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class TestDbJson_List extends BaseTestCase {
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
// we don't update the phone numbers (as they are not dirty)
|
||||
assertSql(sql.get(0)).contains("update ebasic_json_list set bean_set=?, bean_list=?, bean_map=?, plain_bean=?, version=? where id=? and version=?");
|
||||
assertSql(sql.get(0)).contains("update ebasic_json_list set beans=?, bean_list=?, bean_map=?, plain_bean=?, version=? where id=? and version=?");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EBasicJsonList {
|
||||
|
||||
String name;
|
||||
|
||||
@DbJson(length = 700)
|
||||
@DbJson(length = 700, name = "beans")
|
||||
Set<PlainBean> beanSet;
|
||||
|
||||
@DbJsonB
|
||||
|
||||
Reference in New Issue
Block a user