mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
java.util.Date objects are now mapped to DATETIME OType.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.l2jserver.service.database.orientdb;
|
package com.l2jserver.service.database.orientdb;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.sql.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -55,6 +56,7 @@ import com.l2jserver.service.database.dao.SelectMapper;
|
|||||||
import com.l2jserver.service.database.dao.UpdateMapper;
|
import com.l2jserver.service.database.dao.UpdateMapper;
|
||||||
import com.l2jserver.util.CSVUtils;
|
import com.l2jserver.util.CSVUtils;
|
||||||
import com.l2jserver.util.CSVUtils.CSVMapProcessor;
|
import com.l2jserver.util.CSVUtils.CSVMapProcessor;
|
||||||
|
import com.l2jserver.util.ClassUtils;
|
||||||
import com.l2jserver.util.QPathUtils;
|
import com.l2jserver.util.QPathUtils;
|
||||||
import com.l2jserver.util.factory.CollectionFactory;
|
import com.l2jserver.util.factory.CollectionFactory;
|
||||||
import com.mysema.query.sql.ForeignKey;
|
import com.mysema.query.sql.ForeignKey;
|
||||||
@@ -369,19 +371,12 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
|
|||||||
final String name = path.getMetadata().getExpression()
|
final String name = path.getMetadata().getExpression()
|
||||||
.toString();
|
.toString();
|
||||||
OProperty property = schema.getProperty(name);
|
OProperty property = schema.getProperty(name);
|
||||||
|
final OType type = getType(path.getType());
|
||||||
if (property == null)
|
if (property == null)
|
||||||
property = schema.createProperty(
|
property = schema.createProperty(path.getMetadata()
|
||||||
path.getMetadata().getExpression().toString(),
|
.getExpression().toString(), type);
|
||||||
(path.getType().isEnum() ? OType.STRING : OType
|
if (property.getType() != type)
|
||||||
.getTypeByClass(path.getType())));
|
property.setType(type);
|
||||||
if (path.getType().isEnum()) {
|
|
||||||
if (property.getType() != OType.STRING)
|
|
||||||
property.setType(OType.STRING);
|
|
||||||
} else {
|
|
||||||
if (property.getType() != OType.getTypeByClass(path
|
|
||||||
.getType()))
|
|
||||||
property.setType(OType.getTypeByClass(path.getType()));
|
|
||||||
}
|
|
||||||
final boolean nullable = QPathUtils.isNullable(path);
|
final boolean nullable = QPathUtils.isNullable(path);
|
||||||
final boolean autoIncrement = QPathUtils
|
final boolean autoIncrement = QPathUtils
|
||||||
.isAutoIncrementable(path);
|
.isAutoIncrementable(path);
|
||||||
@@ -422,6 +417,24 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
|
|||||||
return newSchema;
|
return newSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link OType} representing the type represented by
|
||||||
|
* {@link Class}
|
||||||
|
*
|
||||||
|
* @param cls
|
||||||
|
* the class
|
||||||
|
* @return the {@link OType}. Never null.
|
||||||
|
*/
|
||||||
|
private OType getType(Class<?> cls) {
|
||||||
|
if (cls.isEnum()) {
|
||||||
|
return OType.STRING;
|
||||||
|
} else if (ClassUtils.isSubclass(cls, Date.class)) {
|
||||||
|
return OType.DATETIME;
|
||||||
|
} else {
|
||||||
|
return OType.getTypeByClass(cls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <I extends ID<?>, O extends Model<?>> O getCachedObject(I id) {
|
public <I extends ID<?>, O extends Model<?>> O getCachedObject(I id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user