Skip to content

Commit

Permalink
jboot v1.4.9 release
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfuhai committed May 3, 2018
1 parent 0687ef3 commit 77295cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
23 changes: 12 additions & 11 deletions src/main/java/io/jboot/db/model/JbootModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ public M copyModel() {
M m = null;
try {
m = (M) _getUsefulClass().newInstance();
Table table = _getTable();
if (table == null) {
throw new JbootException("can't get table of " + _getUsefulClass() + " , maybe config incorrect");
}
Table table = _getTable(true);
Set<String> attrKeys = table.getColumnTypeMap().keySet();
for (String attrKey : attrKeys) {
Object o = this.get(attrKey);
Expand Down Expand Up @@ -597,16 +594,20 @@ public Page<M> paginateByColumns(int pageNumber, int pageSize, List<Column> colu


protected String _getTableName() {
return _getTable().getName();
return _getTable(true).getName();
}

private transient Table table;

protected Table _getTable() {
return _getTable(false);
}

private transient Table table;
protected Table _getTable(boolean validateNull) {
if (table == null) {
table = super._getTable();
if (table == null) {
throw new JbootException(String.format("table of class %s is null, maybe cannot connection to database or not use correct datasource, " +
if (table == null && validateNull) {
throw new JbootException(String.format("class %s can not mapping to database table, maybe cannot connection to database or not use correct datasource, " +
"please check jboot.properties or correct config @Table(datasource=xxx) if you use multi datasource.", _getUsefulClass().getName()));
}
}
Expand All @@ -620,7 +621,7 @@ protected String _getPrimaryKey() {
if (primaryKey != null) {
return primaryKey;
}
String[] primaryKeys = _getTable().getPrimaryKey();
String[] primaryKeys = _getTable(true).getPrimaryKey();
if (null != primaryKeys && primaryKeys.length == 1) {
primaryKey = primaryKeys[0];
}
Expand All @@ -633,14 +634,14 @@ protected String _getPrimaryKey() {

protected Class<?> _getPrimaryType() {
if (primaryType == null) {
primaryType = _getTable().getColumnType(_getPrimaryKey());
primaryType = _getTable(true).getColumnType(_getPrimaryKey());
}
return primaryType;
}


protected boolean hasColumn(String columnLabel) {
return _getTable().hasColumnLabel(columnLabel);
return _getTable(true).hasColumnLabel(columnLabel);
}

// -----------------------------Override----------------------------
Expand Down
1 change: 0 additions & 1 deletion src/test/java/JsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public void testJFinalJson() {
user1.setId(100);
user1.setName(null);


String json1 = JFinalJson.getJson().toJson(user1);
System.out.println(json1);

Expand Down

0 comments on commit 77295cd

Please sign in to comment.