mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
Update for pg - Internal changes for DB Migration / DDL generation #369
This commit is contained in:
1 parent
22407506ff
commit
689d201b04
92 files changed
+2976
-661
No files matched your search
@@ -73,6 +73,11 @@ public class DeployBeanDescriptor<T> {
|
||||
*/
|
||||
private IdType idType;
|
||||
|
||||
/**
|
||||
* Set to true if the identity is default for the platform.
|
||||
*/
|
||||
private boolean idTypePlatformDefault;
|
||||
|
||||
/**
|
||||
* The name of an IdGenerator (optional).
|
||||
*/
|
||||
@@ -545,6 +550,20 @@ public class DeployBeanDescriptor<T> {
|
||||
this.idType = idType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set when the identity type is the platform default.
|
||||
*/
|
||||
public void setIdTypePlatformDefault() {
|
||||
this.idTypePlatformDefault = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true when the identity is the platform default.
|
||||
*/
|
||||
public boolean isIdTypePlatformDefault() {
|
||||
return idTypePlatformDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DB sequence name (can be null).
|
||||
*/
|
||||
@@ -685,6 +704,25 @@ public class DeployBeanDescriptor<T> {
|
||||
return Collections.unmodifiableSet(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the primary key is a compound key or if it's database type
|
||||
* is non-numeric (and hence not suitable for db identity or sequence.
|
||||
*/
|
||||
public boolean isPrimaryKeyCompoundOrNonNumeric() {
|
||||
|
||||
List<DeployBeanProperty> ids = propertiesId();
|
||||
if (ids.size() != 1) {
|
||||
// compound key
|
||||
return true;
|
||||
}
|
||||
DeployBeanProperty p = ids.get(0);
|
||||
if (p instanceof DeployBeanPropertyAssocOne<?>) {
|
||||
return ((DeployBeanPropertyAssocOne<?>)p).isCompound();
|
||||
} else {
|
||||
return !p.isDbNumberType();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Primary Key column assuming it is a single column (not
|
||||
* compound). This is for the purpose of defining a sequence name.
|
||||
|
||||
@@ -625,6 +625,35 @@ public class DeployBeanProperty {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDbNumberType() {
|
||||
return isNumericType(dbType);
|
||||
}
|
||||
|
||||
private boolean isNumericType(int type) {
|
||||
switch (type) {
|
||||
case Types.BIGINT:
|
||||
return true;
|
||||
case Types.DECIMAL:
|
||||
return true;
|
||||
case Types.DOUBLE:
|
||||
return true;
|
||||
case Types.FLOAT:
|
||||
return true;
|
||||
case Types.INTEGER:
|
||||
return true;
|
||||
case Types.NUMERIC:
|
||||
return true;
|
||||
case Types.REAL:
|
||||
return true;
|
||||
case Types.SMALLINT:
|
||||
return true;
|
||||
case Types.TINYINT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return true if this property is based on a secondary table.
|
||||
*/
|
||||
|
||||
+8
@@ -30,6 +30,14 @@ public class DeployBeanPropertyAssocOne<T> extends DeployBeanPropertyAssoc<T> {
|
||||
return deployEmbedded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this has multiple properties (expected for embedded id).
|
||||
*/
|
||||
public boolean isCompound() {
|
||||
// just checking for compound and not doing numeric check at this stage
|
||||
return getDeployEmbedded().getPropertyColumnMap().size() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDbColumn() {
|
||||
DeployTableJoinColumn[] columns = tableJoin.columns();
|
||||
|
||||
Reference in new issue
Block a user