Browse Source

KERNEL-5345 refactor: hibernate特殊处理,使其可以扩展建表时的主键设置语句

release/10.0
lidongy 4 years ago
parent
commit
e90c1be915
  1. 8
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java
  2. 4
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/PrimaryKey.java

8
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java

@ -2783,4 +2783,12 @@ public abstract class Dialect implements ConversionContext {
public boolean supportsNationalizedTypes() {
return true;
}
/**
* 获取主键sql字符串
*
* @param columnList 主键列集合
* @return int
*/
public String getPrimaryKeyString(List<Column> columnList) { return "primary key";}
}

4
fine-hibernate/src/main/java/com/fr/third/org/hibernate/mapping/PrimaryKey.java

@ -6,6 +6,7 @@
*/
package com.fr.third.org.hibernate.mapping;
import java.util.Iterator;
import java.util.List;
import com.fr.third.org.hibernate.dialect.Dialect;
import com.fr.third.org.hibernate.internal.util.StringHelper;
@ -58,7 +59,8 @@ public class PrimaryKey extends Constraint {
}
public String sqlConstraintString(Dialect dialect) {
StringBuilder buf = new StringBuilder("primary key (");
List<Column> columnList = getColumns();
StringBuilder buf = new StringBuilder(dialect.getPrimaryKeyString(columnList)).append(" (");
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
buf.append( ( (Column) iter.next() ).getQuotedName(dialect) );

Loading…
Cancel
Save