mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
Implements insert and update mappers
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
import com.mysema.query.types.Path;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <O>
|
||||
* the object type
|
||||
* @param <R>
|
||||
* the raw id type
|
||||
* @param <I>
|
||||
* the id type
|
||||
* @param <E>
|
||||
* the table type
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractMapper<O, R, I extends ID<? super R>, E extends RelationalPathBase<R>>
|
||||
implements SelectMapper<O, R, I, E>, UpdateMapper<O, E>,
|
||||
InsertMapper<O, R, I, E> {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SelectMapper<I, R, I, E> getIDMapper(E entity) {
|
||||
return new SelectPrimaryKeyMapper<R, I, E>(getPrimaryKeyMapper(),
|
||||
(Path<R>) entity.getPrimaryKey().getLocalColumns().get(0));
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,21 @@ import com.mysema.query.types.Path;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface DatabaseRow {
|
||||
/**
|
||||
* @param <T>
|
||||
* the path type
|
||||
* @param path
|
||||
* the path
|
||||
* @return the value associated in the row for the given {@link Path}
|
||||
*/
|
||||
<T> T get(Path<T> path);
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* the path type
|
||||
* @param path
|
||||
* the path
|
||||
* @return <code>true</code> if the path has a <code>null</code> value
|
||||
*/
|
||||
<T> boolean isNull(Path<T> path);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <O>
|
||||
* the object type
|
||||
* @param <R>
|
||||
* the raw id type
|
||||
* @param <I>
|
||||
* the id type
|
||||
* @param <E>
|
||||
* the table type
|
||||
*/
|
||||
public interface InsertMapper<O, R, I extends ID<? super R>, E extends RelationalPathBase<?>> {
|
||||
/**
|
||||
* Maps the insert values to the <code>row</code>
|
||||
*
|
||||
* @param e
|
||||
* the database table
|
||||
* @param object
|
||||
* the object to be mapped
|
||||
* @param row
|
||||
* the row to be mapped
|
||||
*/
|
||||
void insert(E e, O object, WritableDatabaseRow row);
|
||||
|
||||
/**
|
||||
* @return the {@link PrimaryKeyMapper} that maps {@link ID}s that will be
|
||||
* used for caches
|
||||
*/
|
||||
PrimaryKeyMapper<I, R> getPrimaryKeyMapper();
|
||||
}
|
||||
@@ -16,15 +16,22 @@
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
import com.l2jserver.model.id.ID;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <O>
|
||||
* @param <I>
|
||||
* the object type returned by this mapper
|
||||
* @param <E>
|
||||
* the entity type
|
||||
* @param <R>
|
||||
* the ID raw type
|
||||
*/
|
||||
public interface Mapper<O, E extends RelationalPathBase<?>> {
|
||||
O map(E entity, DatabaseRow row);
|
||||
public interface PrimaryKeyMapper<I extends ID<? super R>, R> {
|
||||
/**
|
||||
* Reads the ID as an object
|
||||
*
|
||||
* @param raw
|
||||
* the raw id
|
||||
* @return the {@link ID} object
|
||||
*/
|
||||
I createID(R raw);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <O>
|
||||
* the object type
|
||||
* @param <R>
|
||||
* the raw id type
|
||||
* @param <I>
|
||||
* the id type
|
||||
* @param <E>
|
||||
* the table type
|
||||
*/
|
||||
public interface SelectMapper<O, R, I extends ID<? super R>, E extends RelationalPathBase<R>> {
|
||||
/**
|
||||
* Reads the {@link DatabaseRow} object into an model object
|
||||
*
|
||||
* @param entity
|
||||
* the entity object (used to execute the select query)
|
||||
* @param row
|
||||
* the database row containing data
|
||||
* @return the created object
|
||||
*/
|
||||
O select(E entity, DatabaseRow row);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the table
|
||||
* @return an wrapper {@link PrimaryKeyMapper} that maps results into
|
||||
* {@link ID}s instead of objects
|
||||
*/
|
||||
SelectMapper<I, R, I, E> getIDMapper(E entity);
|
||||
|
||||
/**
|
||||
* @return the {@link PrimaryKeyMapper} that maps {@link ID}s that will be
|
||||
* used for caches
|
||||
*/
|
||||
PrimaryKeyMapper<I, R> getPrimaryKeyMapper();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
import com.mysema.query.types.Path;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <R>
|
||||
* the primary key raw type
|
||||
* @param <I>
|
||||
* the ID type
|
||||
* @param <E>
|
||||
* the table type
|
||||
*/
|
||||
public class SelectPrimaryKeyMapper<R, I extends ID<? super R>, E extends RelationalPathBase<R>>
|
||||
implements SelectMapper<I, R, I, E> {
|
||||
private final PrimaryKeyMapper<I, R> mapper;
|
||||
private final Path<R> path;
|
||||
|
||||
/**
|
||||
* @param mapper
|
||||
* the {@link PrimaryKeyMapper}
|
||||
* @param path
|
||||
* the {@link Path} to the primary key
|
||||
*/
|
||||
public SelectPrimaryKeyMapper(PrimaryKeyMapper<I, R> mapper, Path<R> path) {
|
||||
this.mapper = mapper;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public I select(E entity, DatabaseRow row) {
|
||||
return mapper.createID(row.get(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectMapper<I, R, I, E> getIDMapper(E entity) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<I, R> getPrimaryKeyMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <O>
|
||||
* the object type returned by this mapper
|
||||
* @param <E>
|
||||
* the entity type
|
||||
*/
|
||||
public interface UpdateMapper<O, E extends RelationalPathBase<?>> {
|
||||
/**
|
||||
* Maps the update values to the <code>row</code>
|
||||
*
|
||||
* @param e
|
||||
* the database table
|
||||
* @param object
|
||||
* the object to be mapped
|
||||
* @param row
|
||||
* the row to be mapped
|
||||
*/
|
||||
void update(E e, O object, WritableDatabaseRow row);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.dao;
|
||||
|
||||
import com.mysema.query.types.Path;
|
||||
|
||||
/**
|
||||
* Database column used to read data
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface WritableDatabaseRow {
|
||||
/**
|
||||
* @param <T>
|
||||
* the path type
|
||||
* @param path
|
||||
* the path
|
||||
* @param value
|
||||
* the value to be set
|
||||
* @return this instance
|
||||
*/
|
||||
<T> WritableDatabaseRow set(Path<T> path, T value);
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* the path type
|
||||
* @param path
|
||||
* the path to be setted to <code>null</code>
|
||||
* @return this instance
|
||||
*/
|
||||
<T> WritableDatabaseRow setNull(Path<T> path);
|
||||
}
|
||||
@@ -61,7 +61,9 @@ import com.l2jserver.service.database.DataAccessObject;
|
||||
import com.l2jserver.service.database.DatabaseException;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.InsertMapper;
|
||||
import com.l2jserver.service.database.dao.SelectMapper;
|
||||
import com.l2jserver.service.database.dao.UpdateMapper;
|
||||
import com.l2jserver.service.database.sql.ddl.QueryFactory;
|
||||
import com.l2jserver.service.database.sql.ddl.TableFactory;
|
||||
import com.l2jserver.service.database.sql.ddl.struct.Table;
|
||||
@@ -70,7 +72,6 @@ import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
import com.mysema.query.sql.SQLQueryFactory;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
import com.mysema.query.sql.types.Type;
|
||||
import com.mysema.query.types.Path;
|
||||
@@ -88,9 +89,9 @@ import com.mysema.query.types.Path;
|
||||
* you do need low level access, feel free to use the {@link Query} class
|
||||
* directly.
|
||||
*
|
||||
* <h2>The {@link Mapper} object</h2>
|
||||
* <h2>The {@link SelectMapper} object</h2>
|
||||
*
|
||||
* The {@link Mapper} object maps an JDBC {@link DatabaseRow} into an Java
|
||||
* The {@link SelectMapper} object maps an JDBC {@link DatabaseRow} into an Java
|
||||
* {@link Object}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
@@ -237,7 +238,7 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "true")
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/updateSchema")
|
||||
String getUpdateSchema();
|
||||
boolean getUpdateSchema();
|
||||
|
||||
/**
|
||||
* @param updateSchema
|
||||
@@ -245,7 +246,7 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/updateSchema")
|
||||
void setUpdateSchema(String updateSchema);
|
||||
void setUpdateSchema(boolean updateSchema);
|
||||
|
||||
/**
|
||||
* @return the maximum number of active connections
|
||||
@@ -345,16 +346,18 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
true);
|
||||
dataSource = new PoolingDataSource(connectionPool);
|
||||
|
||||
try {
|
||||
final Connection conn = dataSource.getConnection();
|
||||
if (config.getUpdateSchema()) {
|
||||
try {
|
||||
ensureDatabaseSchema(conn);
|
||||
} finally {
|
||||
conn.close();
|
||||
final Connection conn = dataSource.getConnection();
|
||||
try {
|
||||
ensureDatabaseSchema(conn);
|
||||
} finally {
|
||||
conn.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceStartException(
|
||||
"Couldn't update database schema", e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceStartException("Couldn't update database schema",
|
||||
e);
|
||||
}
|
||||
|
||||
for (final Type<?> type : sqlTypes) {
|
||||
@@ -570,7 +573,8 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
conn.setAutoCommit(false);
|
||||
}
|
||||
try {
|
||||
return query.query(engine.createSQLQueryFactory(conn));
|
||||
return query
|
||||
.query(engine.createSQLQueryFactory(conn), this);
|
||||
} finally {
|
||||
if (!inTransaction) {
|
||||
conn.commit();
|
||||
@@ -659,9 +663,12 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
*
|
||||
* @param factory
|
||||
* the query factory (database specific)
|
||||
* @param database
|
||||
* the database service instance
|
||||
* @return the query return value
|
||||
*/
|
||||
R query(SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory);
|
||||
R query(SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||
DatabaseService database);
|
||||
}
|
||||
|
||||
public static abstract class AbstractQuery<R> implements Query<R> {
|
||||
@@ -674,24 +681,29 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class InsertQuery<O, E extends RelationalPathBase<?>, K>
|
||||
public static class InsertQuery<O, RI, I extends ID<? super RI>, E extends RelationalPathBase<?>>
|
||||
extends AbstractQuery<Integer> {
|
||||
private final InsertMapper<O, RI, I, E> mapper;
|
||||
private final Iterator<O> iterator;
|
||||
private final Path<K> primaryKey;
|
||||
private final Path<RI> primaryKey;
|
||||
|
||||
protected final E e;
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the entity type
|
||||
* @param mapper
|
||||
* the insert mapper
|
||||
* @param iterator
|
||||
* the objects to be inserted
|
||||
* @param primaryKey
|
||||
* the primary key, if any. Only required if the ID is
|
||||
* generated by the database engine.
|
||||
*/
|
||||
public InsertQuery(E entity, Path<K> primaryKey, Iterator<O> iterator) {
|
||||
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||
Path<RI> primaryKey, Iterator<O> iterator) {
|
||||
this.iterator = iterator;
|
||||
this.mapper = mapper;
|
||||
this.e = entity;
|
||||
this.primaryKey = primaryKey;
|
||||
}
|
||||
@@ -699,27 +711,35 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
/**
|
||||
* @param entity
|
||||
* the entity type
|
||||
* @param mapper
|
||||
* the insert mapper
|
||||
* @param iterator
|
||||
* the objects to be inserted
|
||||
*/
|
||||
public InsertQuery(E entity, Iterator<O> iterator) {
|
||||
this(entity, null, iterator);
|
||||
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||
Iterator<O> iterator) {
|
||||
this(entity, mapper, null, iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the entity type
|
||||
* @param mapper
|
||||
* the insert mapper
|
||||
* @param objects
|
||||
* the objects to be inserted
|
||||
*/
|
||||
@SafeVarargs
|
||||
public InsertQuery(E entity, O... objects) {
|
||||
this(entity, null, Iterators.forArray(objects));
|
||||
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||
O... objects) {
|
||||
this(entity, mapper, null, Iterators.forArray(objects));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the entity type
|
||||
* @param mapper
|
||||
* the insert mapper
|
||||
* @param objects
|
||||
* the objects to be inserted
|
||||
* @param primaryKey
|
||||
@@ -727,25 +747,31 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
* generated by the database engine.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public InsertQuery(E entity, Path<K> primaryKey, O... objects) {
|
||||
this(entity, primaryKey, Iterators.forArray(objects));
|
||||
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||
Path<RI> primaryKey, O... objects) {
|
||||
this(entity, mapper, primaryKey, Iterators.forArray(objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final Integer query(
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||
DatabaseService database) {
|
||||
int rows = 0;
|
||||
while (iterator.hasNext()) {
|
||||
final O object = iterator.next();
|
||||
final SQLInsertClause insert = factory.insert(e);
|
||||
// maps query to the values
|
||||
map(insert, object);
|
||||
final SQLInsertWritableDatabaseRow row = new SQLInsertWritableDatabaseRow(
|
||||
factory.insert(e));
|
||||
mapper.insert(e, object, row);
|
||||
|
||||
if (primaryKey == null) {
|
||||
insert.execute();
|
||||
row.getClause().execute();
|
||||
} else {
|
||||
final K key = insert.executeWithKey(primaryKey);
|
||||
key(key, object);
|
||||
final RI key = row.getClause().executeWithKey(primaryKey);
|
||||
final I id = mapper.getPrimaryKeyMapper().createID(key);
|
||||
if (object instanceof Model) {
|
||||
((Model<I>) object).setID(id);
|
||||
}
|
||||
}
|
||||
rows++;
|
||||
|
||||
@@ -753,52 +779,56 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
protected abstract void map(SQLInsertClause q, O o);
|
||||
|
||||
protected void key(K k, O o) {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class UpdateQuery<O, E extends RelationalPathBase<?>>
|
||||
extends AbstractQuery<Integer> {
|
||||
private final UpdateMapper<O, E> mapper;
|
||||
private final Iterator<O> iterator;
|
||||
protected final E e;
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the entity type
|
||||
* @param mapper
|
||||
* the update mapper
|
||||
* @param iterator
|
||||
* the objects to be inserted
|
||||
*/
|
||||
public UpdateQuery(E entity, Iterator<O> iterator) {
|
||||
public UpdateQuery(E entity, UpdateMapper<O, E> mapper,
|
||||
Iterator<O> iterator) {
|
||||
this.iterator = iterator;
|
||||
this.mapper = mapper;
|
||||
this.e = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the entity type
|
||||
* @param mapper
|
||||
* the update mapper
|
||||
* @param objects
|
||||
* the objects to be inserted
|
||||
*/
|
||||
@SafeVarargs
|
||||
public UpdateQuery(E entity, O... objects) {
|
||||
this(entity, Iterators.forArray(objects));
|
||||
public UpdateQuery(E entity, UpdateMapper<O, E> mapper, O... objects) {
|
||||
this(entity, mapper, Iterators.forArray(objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer query(
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||
DatabaseService database) {
|
||||
int rows = 0;
|
||||
while (iterator.hasNext()) {
|
||||
final O object = iterator.next();
|
||||
final SQLUpdateClause update = factory.update(e);
|
||||
final SQLUpdateWritableDatabaseRow row = new SQLUpdateWritableDatabaseRow(
|
||||
factory.update(e));
|
||||
// maps query to the values
|
||||
query(update, object);
|
||||
map(update, object);
|
||||
query(row.getClause(), object);
|
||||
mapper.update(e, object, row);
|
||||
|
||||
rows += update.execute();
|
||||
rows += row.getClause().execute();
|
||||
|
||||
updateDesire(object, ObjectDesire.UPDATE);
|
||||
}
|
||||
@@ -806,8 +836,6 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
}
|
||||
|
||||
protected abstract void query(SQLUpdateClause q, O o);
|
||||
|
||||
protected abstract void map(SQLUpdateClause q, O o);
|
||||
}
|
||||
|
||||
public static abstract class DeleteQuery<O, E extends RelationalPathBase<?>>
|
||||
@@ -839,7 +867,8 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
|
||||
@Override
|
||||
public final Integer query(
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||
DatabaseService database) {
|
||||
int rows = 0;
|
||||
while (iterator.hasNext()) {
|
||||
final O object = iterator.next();
|
||||
@@ -857,10 +886,10 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
protected abstract void query(SQLDeleteClause q, O o);
|
||||
}
|
||||
|
||||
public static abstract class AbstractSelectQuery<R, O, E extends RelationalPathBase<?>>
|
||||
public static abstract class AbstractSelectQuery<R, O, RI, I extends ID<? super RI>, E extends RelationalPathBase<RI>>
|
||||
extends AbstractQuery<R> {
|
||||
protected final E entity;
|
||||
protected final Mapper<O, E> mapper;
|
||||
protected final SelectMapper<O, RI, I, E> mapper;
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
@@ -868,70 +897,107 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
* @param mapper
|
||||
* the object mapper
|
||||
*/
|
||||
public AbstractSelectQuery(E entity, Mapper<O, E> mapper) {
|
||||
public AbstractSelectQuery(E entity, SelectMapper<O, RI, I, E> mapper) {
|
||||
this.entity = entity;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final R query(
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||
DatabaseService database) {
|
||||
final AbstractSQLQuery<?> select = factory.query();
|
||||
// maps query to the values
|
||||
select.from(entity);
|
||||
query(select, entity);
|
||||
return perform(select);
|
||||
return perform(select, database);
|
||||
}
|
||||
|
||||
protected abstract void query(AbstractSQLQuery<?> q, E e);
|
||||
|
||||
protected abstract R perform(AbstractSQLQuery<?> select);
|
||||
protected abstract R perform(AbstractSQLQuery<?> select,
|
||||
DatabaseService database);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected O lookupCache(DatabaseRow row, DatabaseService database) {
|
||||
final I id = mapper.getPrimaryKeyMapper().createID(
|
||||
(RI) row.get(entity.getPrimaryKey().getLocalColumns()
|
||||
.get(0)));
|
||||
|
||||
if (id != null) {
|
||||
if (database.hasCachedObject(id))
|
||||
return (O) database.getCachedObject(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void updateCache(O instance, DatabaseService database) {
|
||||
if (instance == null)
|
||||
return;
|
||||
if (instance instanceof Model)
|
||||
database.updateCache(((Model<?>) instance).getID(),
|
||||
(Model<?>) instance);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class SelectSingleQuery<O, E extends RelationalPathBase<?>>
|
||||
extends AbstractSelectQuery<O, O, E> {
|
||||
public static abstract class SelectSingleQuery<O, RI, I extends ID<? super RI>, E extends RelationalPathBase<RI>>
|
||||
extends AbstractSelectQuery<O, O, RI, I, E> {
|
||||
/**
|
||||
* @param entity
|
||||
* the entity
|
||||
* @param mapper
|
||||
* the mapper
|
||||
*/
|
||||
public SelectSingleQuery(E entity, Mapper<O, E> mapper) {
|
||||
public SelectSingleQuery(E entity, SelectMapper<O, RI, I, E> mapper) {
|
||||
super(entity, mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final O perform(AbstractSQLQuery<?> select) {
|
||||
protected final O perform(AbstractSQLQuery<?> select,
|
||||
DatabaseService database) {
|
||||
final List<Object[]> results = select.limit(1).list(entity.all());
|
||||
if (results.size() == 1) {
|
||||
return mapper.map(entity, new SQLDatabaseRow(results.get(0),
|
||||
entity));
|
||||
final DatabaseRow row = new SQLDatabaseRow(results.get(0),
|
||||
entity);
|
||||
O object = lookupCache(row, database);
|
||||
if (object == null) {
|
||||
object = mapper.select(entity,
|
||||
new SQLDatabaseRow(results.get(0), entity));
|
||||
updateCache(object, database);
|
||||
}
|
||||
return object;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class SelectListQuery<O, E extends RelationalPathBase<?>>
|
||||
extends AbstractSelectQuery<List<O>, O, E> {
|
||||
public static abstract class SelectListQuery<O, RI, I extends ID<? super RI>, E extends RelationalPathBase<RI>>
|
||||
extends AbstractSelectQuery<List<O>, O, RI, I, E> {
|
||||
/**
|
||||
* @param entity
|
||||
* the entity
|
||||
* @param mapper
|
||||
* the mapper
|
||||
*/
|
||||
public SelectListQuery(E entity, Mapper<O, E> mapper) {
|
||||
public SelectListQuery(E entity, SelectMapper<O, RI, I, E> mapper) {
|
||||
super(entity, mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final List<O> perform(AbstractSQLQuery<?> select) {
|
||||
protected final List<O> perform(AbstractSQLQuery<?> select,
|
||||
DatabaseService database) {
|
||||
final List<Object[]> results = select.list(entity.all());
|
||||
final SQLDatabaseRow row = new SQLDatabaseRow(entity);
|
||||
final List<O> objects = CollectionFactory.newList();
|
||||
for (final Object[] data : results) {
|
||||
row.setRow(data);
|
||||
final O object = mapper.map(entity, row);
|
||||
|
||||
O object = lookupCache(row, database);
|
||||
if (object == null) {
|
||||
object = mapper.select(entity, row);
|
||||
updateCache(object, database);
|
||||
}
|
||||
if (object != null)
|
||||
objects.add(object);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.types.Path;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class SQLInsertWritableDatabaseRow implements WritableDatabaseRow {
|
||||
/**
|
||||
* The SQL <code>INSERT</code> clause
|
||||
*/
|
||||
private final SQLInsertClause clause;
|
||||
|
||||
/**
|
||||
* @param clause
|
||||
* the insert clause
|
||||
*/
|
||||
public SQLInsertWritableDatabaseRow(SQLInsertClause clause) {
|
||||
this.clause = clause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> WritableDatabaseRow set(Path<T> path, T value) {
|
||||
clause.set(path, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> WritableDatabaseRow setNull(Path<T> path) {
|
||||
return set(path, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the insert clause
|
||||
*/
|
||||
public SQLInsertClause getClause() {
|
||||
return clause;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
import com.mysema.query.types.Path;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class SQLUpdateWritableDatabaseRow implements WritableDatabaseRow {
|
||||
/**
|
||||
* The SQL <code>UPDATE</code> clause
|
||||
*/
|
||||
private final SQLUpdateClause clause;
|
||||
|
||||
/**
|
||||
* @param clause
|
||||
* the update clause
|
||||
*/
|
||||
public SQLUpdateWritableDatabaseRow(SQLUpdateClause clause) {
|
||||
this.clause = clause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> WritableDatabaseRow set(Path<T> path, T value) {
|
||||
clause.set(path, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> WritableDatabaseRow setNull(Path<T> path) {
|
||||
return set(path, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the update clause
|
||||
*/
|
||||
public SQLUpdateClause getClause() {
|
||||
return clause;
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@
|
||||
<database>
|
||||
<jdbc>
|
||||
<!-- Defines the connection URL used by JDBC to connect to the database. -->
|
||||
<url>jdbc:derby:data/database/derby;create=true</url>
|
||||
<url>jdbc:mysql://localhost/l2jserver2</url>
|
||||
|
||||
<!-- The engine used to connect to the database. -->
|
||||
<engine>com.l2jserver.service.database.sql.DerbyDatabaseEngine</engine>
|
||||
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine</engine>
|
||||
|
||||
<!-- Whether or not the service should try to update and create missing
|
||||
tables at startup. This should be disabled after the first server start as
|
||||
|
||||
@@ -26,13 +26,13 @@ import com.l2jserver.model.dao.ChatMessageDAO;
|
||||
import com.l2jserver.model.dao.ClanDAO;
|
||||
import com.l2jserver.model.dao.ItemDAO;
|
||||
import com.l2jserver.model.dao.NPCDAO;
|
||||
import com.l2jserver.service.database.sql.SQLCharacterDAO;
|
||||
import com.l2jserver.service.database.sql.SQLCharacterFriendDAO;
|
||||
import com.l2jserver.service.database.sql.SQLCharacterShortcutDAO;
|
||||
import com.l2jserver.service.database.sql.SQLChatMessageDAO;
|
||||
import com.l2jserver.service.database.sql.SQLClanDAO;
|
||||
import com.l2jserver.service.database.sql.SQLItemDAO;
|
||||
import com.l2jserver.service.database.sql.SQLNPCDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLCharacterDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLCharacterFriendDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLCharacterShortcutDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLChatMessageDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLClanDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLItemDAO;
|
||||
import com.l2jserver.service.database.dao.sql.SQLNPCDAO;
|
||||
|
||||
/**
|
||||
* Google Guice {@link Module} for JDBC DAOs
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingl
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
|
||||
/**
|
||||
@@ -65,127 +64,82 @@ public class SQLCharacterDAO extends AbstractSQLDAO<L2Character, CharacterID>
|
||||
|
||||
@Override
|
||||
public L2Character select(final CharacterID id) {
|
||||
return database.query(new SelectSingleQuery<L2Character, QCharacter>(
|
||||
QCharacter.character, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.characterId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectSingleQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.characterId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(final Clan clan) {
|
||||
clan.getMembers().load(database.query(new SelectListQuery<CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper.getIDMapper()) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.clanId.eq(clan.getID().getID()));
|
||||
}
|
||||
}));
|
||||
clan.getMembers()
|
||||
.load(database
|
||||
.query(new SelectListQuery<CharacterID, Integer, CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper
|
||||
.getIDMapper(QCharacter.character)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
QCharacter e) {
|
||||
q.where(e.clanId.eq(clan.getID().getID()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Character selectByName(final String name) {
|
||||
return database.query(new SelectSingleQuery<L2Character, QCharacter>(
|
||||
QCharacter.character, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.name.eq(name));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectSingleQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.name.eq(name));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<L2Character> selectByAccount(final AccountID account) {
|
||||
return database.query(new SelectListQuery<L2Character, QCharacter>(
|
||||
QCharacter.character, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.accountId.eq(account.getID()));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
q.where(e.accountId.eq(account.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CharacterID> selectIDs() {
|
||||
return database.query(new SelectListQuery<CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper.getIDMapper()) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<CharacterID, Integer, CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper
|
||||
.getIDMapper(QCharacter.character)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertObjects(L2Character... characters) {
|
||||
return database.query(new InsertQuery<L2Character, QCharacter, Object>(
|
||||
QCharacter.character, characters) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, L2Character o) {
|
||||
q.set(e.characterId, o.getID().getID())
|
||||
.set(e.accountId, o.getAccountID().getID())
|
||||
.set(e.clanId,
|
||||
(o.getClanID() != null ? o.getClanID().getID()
|
||||
: null))
|
||||
.set(e.name, o.getName())
|
||||
.set(e.race, o.getRace())
|
||||
.set(e.characterClass, o.getCharacterClass())
|
||||
.set(e.sex, o.getSex())
|
||||
.set(e.level, o.getLevel())
|
||||
.set(e.experience, o.getExperience())
|
||||
.set(e.sp, o.getSP())
|
||||
.set(e.hp, o.getHP())
|
||||
.set(e.mp, o.getMP())
|
||||
.set(e.cp, o.getCP())
|
||||
.set(e.pointX, o.getPoint().getX())
|
||||
.set(e.pointY, o.getPoint().getY())
|
||||
.set(e.pointZ, o.getPoint().getZ())
|
||||
.set(e.pointAngle, o.getPoint().getAngle())
|
||||
.set(e.appearanceHairStyle,
|
||||
o.getAppearance().getHairStyle())
|
||||
.set(e.appearanceHairColor,
|
||||
o.getAppearance().getHairColor())
|
||||
.set(e.apperanceFace, o.getAppearance().getFace());
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new InsertQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||
QCharacter.character, mapper, characters));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateObjects(L2Character... characters) {
|
||||
return database.query(new UpdateQuery<L2Character, QCharacter>(
|
||||
QCharacter.character, characters) {
|
||||
QCharacter.character, mapper, characters) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, L2Character o) {
|
||||
q.where(e.characterId.eq(o.getID().getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map(SQLUpdateClause q, L2Character o) {
|
||||
q.set(e.accountId, o.getAccountID().getID())
|
||||
.set(e.clanId,
|
||||
(o.getClanID() != null ? o.getClanID().getID()
|
||||
: null))
|
||||
.set(e.name, o.getName())
|
||||
.set(e.race, o.getRace())
|
||||
.set(e.characterClass, o.getCharacterClass())
|
||||
.set(e.sex, o.getSex())
|
||||
.set(e.level, o.getLevel())
|
||||
.set(e.experience, o.getExperience())
|
||||
.set(e.sp, o.getSP())
|
||||
.set(e.hp, o.getHP())
|
||||
.set(e.mp, o.getMP())
|
||||
.set(e.cp, o.getCP())
|
||||
.set(e.pointX, o.getPoint().getX())
|
||||
.set(e.pointY, o.getPoint().getY())
|
||||
.set(e.pointZ, o.getPoint().getZ())
|
||||
.set(e.pointAngle, o.getPoint().getAngle())
|
||||
.set(e.appearanceHairStyle,
|
||||
o.getAppearance().getHairStyle())
|
||||
.set(e.appearanceHairColor,
|
||||
o.getAppearance().getHairColor())
|
||||
.set(e.apperanceFace, o.getAppearance().getFace());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectListQ
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingleQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
|
||||
/**
|
||||
* {@link CharacterFriendDAO} implementation for JDBC
|
||||
@@ -43,8 +42,7 @@ import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SQLCharacterFriendDAO extends
|
||||
AbstractSQLDAO<CharacterFriend, FriendID> implements
|
||||
CharacterFriendDAO {
|
||||
AbstractSQLDAO<CharacterFriend, FriendID> implements CharacterFriendDAO {
|
||||
/**
|
||||
* The {@link CharacterFriend} mapper
|
||||
*/
|
||||
@@ -66,7 +64,7 @@ public class SQLCharacterFriendDAO extends
|
||||
@Override
|
||||
public CharacterFriend select(final FriendID id) {
|
||||
return database
|
||||
.query(new SelectSingleQuery<CharacterFriend, QCharacterFriend>(
|
||||
.query(new SelectSingleQuery<CharacterFriend, FriendID, FriendID, QCharacterFriend>(
|
||||
QCharacterFriend.characterFriend, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
@@ -81,7 +79,7 @@ public class SQLCharacterFriendDAO extends
|
||||
@Override
|
||||
public void load(final L2Character character) {
|
||||
final List<CharacterFriend> list = database
|
||||
.query(new SelectListQuery<CharacterFriend, QCharacterFriend>(
|
||||
.query(new SelectListQuery<CharacterFriend, FriendID, FriendID, QCharacterFriend>(
|
||||
QCharacterFriend.characterFriend, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
@@ -94,25 +92,22 @@ public class SQLCharacterFriendDAO extends
|
||||
|
||||
@Override
|
||||
public List<FriendID> selectIDs() {
|
||||
return database.query(new SelectListQuery<FriendID, QCharacterFriend>(
|
||||
QCharacterFriend.characterFriend, mapper.getIDMapper()) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QCharacterFriend e) {
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<FriendID, FriendID, FriendID, QCharacterFriend>(
|
||||
QCharacterFriend.characterFriend, mapper
|
||||
.getIDMapper(QCharacterFriend.characterFriend)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
QCharacterFriend e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertObjects(CharacterFriend... friends) {
|
||||
return database
|
||||
.query(new InsertQuery<CharacterFriend, QCharacterFriend, Object>(
|
||||
QCharacterFriend.characterFriend, friends) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, CharacterFriend o) {
|
||||
q.set(e.characterId, o.getCharacterID().getID()).set(
|
||||
e.characterIdFriend, o.getFriendID().getID());
|
||||
}
|
||||
});
|
||||
.query(new InsertQuery<CharacterFriend, FriendID, FriendID, QCharacterFriend>(
|
||||
QCharacterFriend.characterFriend, mapper, friends));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingl
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
|
||||
/**
|
||||
@@ -65,7 +64,7 @@ public class SQLCharacterShortcutDAO extends
|
||||
@Override
|
||||
public CharacterShortcut select(final CharacterShortcutID id) {
|
||||
return database
|
||||
.query(new SelectSingleQuery<CharacterShortcut, QCharacterShortcut>(
|
||||
.query(new SelectSingleQuery<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||
QCharacterShortcut.characterShortcut, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
@@ -78,7 +77,7 @@ public class SQLCharacterShortcutDAO extends
|
||||
@Override
|
||||
public List<CharacterShortcut> selectByCharacter(final L2Character character) {
|
||||
return database
|
||||
.query(new SelectListQuery<CharacterShortcut, QCharacterShortcut>(
|
||||
.query(new SelectListQuery<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||
QCharacterShortcut.characterShortcut, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
@@ -91,9 +90,9 @@ public class SQLCharacterShortcutDAO extends
|
||||
@Override
|
||||
public List<CharacterShortcutID> selectIDs() {
|
||||
return database
|
||||
.query(new SelectListQuery<CharacterShortcutID, QCharacterShortcut>(
|
||||
QCharacterShortcut.characterShortcut, mapper
|
||||
.getIDMapper()) {
|
||||
.query(new SelectListQuery<CharacterShortcutID, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||
QCharacterShortcut.characterShortcut,
|
||||
mapper.getIDMapper(QCharacterShortcut.characterShortcut)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q,
|
||||
QCharacterShortcut e) {
|
||||
@@ -104,44 +103,21 @@ public class SQLCharacterShortcutDAO extends
|
||||
@Override
|
||||
public int insertObjects(CharacterShortcut... shortcuts) {
|
||||
return database
|
||||
.query(new InsertQuery<CharacterShortcut, QCharacterShortcut, Integer>(
|
||||
QCharacterShortcut.characterShortcut,
|
||||
.query(new InsertQuery<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||
QCharacterShortcut.characterShortcut, mapper,
|
||||
QCharacterShortcut.characterShortcut.shortcutId,
|
||||
shortcuts) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, CharacterShortcut o) {
|
||||
q.set(e.characterId, o.getID().getID())
|
||||
.set(e.type, o.getType())
|
||||
.set(e.objectId, o.getItemID().getID())
|
||||
.set(e.slot, o.getSlot())
|
||||
.set(e.page, o.getPage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void key(Integer k, CharacterShortcut o) {
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
shortcuts));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateObjects(CharacterShortcut... shortcuts) {
|
||||
return database
|
||||
.query(new UpdateQuery<CharacterShortcut, QCharacterShortcut>(
|
||||
QCharacterShortcut.characterShortcut, shortcuts) {
|
||||
QCharacterShortcut.characterShortcut, mapper, shortcuts) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, CharacterShortcut o) {
|
||||
q.where(e.shortcutId.eq(o.getID().getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map(SQLUpdateClause q, CharacterShortcut o) {
|
||||
q.set(e.characterId, o.getID().getID())
|
||||
.set(e.type, o.getType())
|
||||
.set(e.objectId, o.getItemID().getID())
|
||||
.set(e.slot, o.getSlot())
|
||||
.set(e.page, o.getPage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -32,11 +32,8 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.DeleteQuery
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.InsertQuery;
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectListQuery;
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingleQuery;
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
|
||||
/**
|
||||
* {@link CharacterDAO} implementation for JDBC
|
||||
@@ -61,70 +58,38 @@ public class SQLChatMessageDAO extends
|
||||
|
||||
@Override
|
||||
public ChatMessage select(final ChatMessageID id) {
|
||||
return database.query(new SelectSingleQuery<ChatMessage, QLogChat>(
|
||||
QLogChat.logChat, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
||||
q.where(e.messageId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectSingleQuery<ChatMessage, Integer, ChatMessageID, QLogChat>(
|
||||
QLogChat.logChat, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
||||
q.where(e.messageId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ChatMessageID> selectIDs() {
|
||||
return database.query(new SelectListQuery<ChatMessageID, QLogChat>(
|
||||
QLogChat.logChat, mapper.getIDMapper()) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<ChatMessageID, Integer, ChatMessageID, QLogChat>(
|
||||
QLogChat.logChat, mapper.getIDMapper(QLogChat.logChat)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertObjects(ChatMessage... objects) {
|
||||
return database.query(new InsertQuery<ChatMessage, QLogChat, Integer>(
|
||||
QLogChat.logChat, QLogChat.logChat.messageId, objects) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, ChatMessage o) {
|
||||
q.set(e.type, o.getType()).set(e.sender, o.getSender().getID())
|
||||
.set(e.date, o.getDate())
|
||||
.set(e.message, o.getMessage());
|
||||
switch (o.getType()) {
|
||||
case SHOUT:
|
||||
q.set(e.channelId, o.getTarget().getID());
|
||||
break;
|
||||
default:
|
||||
q.set(e.channelId, o.getChannelID());
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new InsertQuery<ChatMessage, Integer, ChatMessageID, QLogChat>(
|
||||
QLogChat.logChat, mapper, QLogChat.logChat.messageId,
|
||||
objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateObjects(ChatMessage... objects) {
|
||||
return database.query(new UpdateQuery<ChatMessage, QLogChat>(
|
||||
QLogChat.logChat, objects) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, ChatMessage o) {
|
||||
q.where(e.messageId.eq(o.getID().getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map(SQLUpdateClause q, ChatMessage o) {
|
||||
q.set(e.type, o.getType()).set(e.sender, o.getSender().getID())
|
||||
.set(e.date, o.getDate())
|
||||
.set(e.message, o.getMessage());
|
||||
switch (o.getType()) {
|
||||
case SHOUT:
|
||||
q.set(e.channelId, o.getTarget().getID());
|
||||
break;
|
||||
default:
|
||||
q.set(e.channelId, o.getChannelID());
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingl
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
|
||||
/**
|
||||
@@ -43,8 +42,7 @@ import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SQLClanDAO extends AbstractSQLDAO<Clan, ClanID> implements
|
||||
ClanDAO {
|
||||
public class SQLClanDAO extends AbstractSQLDAO<Clan, ClanID> implements ClanDAO {
|
||||
private final ClanMapper mapper;
|
||||
|
||||
/**
|
||||
@@ -61,52 +59,42 @@ public class SQLClanDAO extends AbstractSQLDAO<Clan, ClanID> implements
|
||||
|
||||
@Override
|
||||
public Clan select(final ClanID id) {
|
||||
return database.query(new SelectSingleQuery<Clan, QClan>(QClan.clan,
|
||||
mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
||||
q.where(e.clanId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectSingleQuery<Clan, Integer, ClanID, QClan>(
|
||||
QClan.clan, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
||||
q.where(e.clanId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ClanID> selectIDs() {
|
||||
return database.query(new SelectListQuery<ClanID, QClan>(QClan.clan,
|
||||
mapper.getIDMapper()) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<ClanID, Integer, ClanID, QClan>(
|
||||
QClan.clan, mapper.getIDMapper(QClan.clan)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertObjects(Clan... objects) {
|
||||
return database.query(new InsertQuery<Clan, QClan, Integer>(QClan.clan,
|
||||
QClan.clan.clanId, objects) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, Clan o) {
|
||||
q.set(e.clanId, o.getID().getID()).set(e.characterIdLeader,
|
||||
o.getLeaderID().getID());
|
||||
}
|
||||
});
|
||||
return database.query(new InsertQuery<Clan, Integer, ClanID, QClan>(
|
||||
QClan.clan, mapper, QClan.clan.clanId, objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateObjects(Clan... objects) {
|
||||
return database
|
||||
.query(new UpdateQuery<Clan, QClan>(QClan.clan, objects) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, Clan o) {
|
||||
q.where(e.clanId.eq(o.getID().getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map(SQLUpdateClause q, Clan o) {
|
||||
q.set(e.clanId, o.getID().getID()).set(
|
||||
e.characterIdLeader, o.getLeaderID().getID());
|
||||
}
|
||||
});
|
||||
return database.query(new UpdateQuery<Clan, QClan>(QClan.clan, mapper,
|
||||
objects) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, Clan o) {
|
||||
q.where(e.clanId.eq(o.getID().getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -37,7 +37,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingl
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
|
||||
/**
|
||||
@@ -45,8 +44,7 @@ import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SQLItemDAO extends AbstractSQLDAO<Item, ItemID> implements
|
||||
ItemDAO {
|
||||
public class SQLItemDAO extends AbstractSQLDAO<Item, ItemID> implements ItemDAO {
|
||||
private final ItemMapper mapper;
|
||||
|
||||
/**
|
||||
@@ -63,103 +61,66 @@ public class SQLItemDAO extends AbstractSQLDAO<Item, ItemID> implements
|
||||
|
||||
@Override
|
||||
public Item select(final ItemID id) {
|
||||
return database.query(new SelectSingleQuery<Item, QItem>(QItem.item,
|
||||
mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
q.where(e.itemId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectSingleQuery<Item, Integer, ItemID, QItem>(
|
||||
QItem.item, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
q.where(e.itemId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Item> selectByCharacter(final L2Character character) {
|
||||
return database.query(new SelectListQuery<Item, QItem>(QItem.item,
|
||||
mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
q.where(e.characterId.eq(character.getID().getID()));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<Item, Integer, ItemID, QItem>(
|
||||
QItem.item, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
q.where(e.characterId.eq(character.getID().getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Item> selectDroppedItems() {
|
||||
return database.query(new SelectListQuery<Item, QItem>(QItem.item,
|
||||
mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
q.where(e.location.eq(ItemLocation.GROUND));
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<Item, Integer, ItemID, QItem>(
|
||||
QItem.item, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
q.where(e.location.eq(ItemLocation.GROUND));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemID> selectIDs() {
|
||||
return database.query(new SelectListQuery<ItemID, QItem>(QItem.item,
|
||||
mapper.getIDMapper()) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
}
|
||||
});
|
||||
return database
|
||||
.query(new SelectListQuery<ItemID, Integer, ItemID, QItem>(
|
||||
QItem.item, mapper.getIDMapper(QItem.item)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertObjects(Item... objects) {
|
||||
return database.query(new InsertQuery<Item, QItem, Object>(QItem.item,
|
||||
objects) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, Item o) {
|
||||
q.set(e.itemId, o.getID().getID())
|
||||
.set(e.templateId, o.getTemplateID().getID())
|
||||
.set(e.characterId,
|
||||
(o.getOwnerID() != null ? o.getOwnerID()
|
||||
.getID() : null))
|
||||
.set(e.location, o.getLocation())
|
||||
.set(e.paperdoll, o.getPaperdoll())
|
||||
.set(e.count, o.getCount())
|
||||
.set(e.coordX,
|
||||
(o.getPoint() != null ? o.getPoint().getX()
|
||||
: null))
|
||||
.set(e.coordY,
|
||||
(o.getPoint() != null ? o.getPoint().getY()
|
||||
: null))
|
||||
.set(e.coordZ,
|
||||
(o.getPoint() != null ? o.getPoint().getZ()
|
||||
: null));
|
||||
}
|
||||
});
|
||||
return database.query(new InsertQuery<Item, Integer, ItemID, QItem>(
|
||||
QItem.item, mapper, objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateObjects(Item... objects) {
|
||||
return database
|
||||
.query(new UpdateQuery<Item, QItem>(QItem.item, objects) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, Item o) {
|
||||
q.where(e.itemId.eq(o.getID().getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map(SQLUpdateClause q, Item o) {
|
||||
q.set(e.templateId, o.getTemplateID().getID())
|
||||
.set(e.characterId,
|
||||
(o.getOwnerID() != null ? o
|
||||
.getOwnerID().getID() : null))
|
||||
.set(e.location, o.getLocation())
|
||||
.set(e.paperdoll, o.getPaperdoll())
|
||||
.set(e.count, o.getCount())
|
||||
.set(e.coordX,
|
||||
(o.getPoint() != null ? o.getPoint()
|
||||
.getX() : null))
|
||||
.set(e.coordY,
|
||||
(o.getPoint() != null ? o.getPoint()
|
||||
.getY() : null))
|
||||
.set(e.coordZ,
|
||||
(o.getPoint() != null ? o.getPoint()
|
||||
.getZ() : null));
|
||||
}
|
||||
});
|
||||
return database.query(new UpdateQuery<Item, QItem>(QItem.item, mapper,
|
||||
objects) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, Item o) {
|
||||
q.where(e.itemId.eq(o.getID().getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
package com.l2jserver.service.database.dao.sql;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -37,7 +37,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingl
|
||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||
import com.mysema.query.sql.AbstractSQLQuery;
|
||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
||||
import com.mysema.query.sql.dml.SQLUpdateClause;
|
||||
|
||||
/**
|
||||
@@ -62,18 +61,19 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
||||
|
||||
@Override
|
||||
public NPC select(final NPCID id) {
|
||||
return database
|
||||
.query(new SelectSingleQuery<NPC, QNPC>(QNPC.npc, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||
q.where(e.npcId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
return database.query(new SelectSingleQuery<NPC, Integer, NPCID, QNPC>(
|
||||
QNPC.npc, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||
q.where(e.npcId.eq(id.getID()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<NPC> loadAll() {
|
||||
return database.query(new SelectListQuery<NPC, QNPC>(QNPC.npc, mapper) {
|
||||
return database.query(new SelectListQuery<NPC, Integer, NPCID, QNPC>(
|
||||
QNPC.npc, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||
}
|
||||
@@ -82,7 +82,8 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
||||
|
||||
@Override
|
||||
public List<NPC> selectByTemplate(final NPCTemplateID templateID) {
|
||||
return database.query(new SelectListQuery<NPC, QNPC>(QNPC.npc, mapper) {
|
||||
return database.query(new SelectListQuery<NPC, Integer, NPCID, QNPC>(
|
||||
QNPC.npc, mapper) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||
q.where(e.npcTemplateId.eq(templateID.getID()));
|
||||
@@ -92,8 +93,8 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
||||
|
||||
@Override
|
||||
public Collection<NPCID> selectIDs() {
|
||||
return database.query(new SelectListQuery<NPCID, QNPC>(QNPC.npc, mapper
|
||||
.getIDMapper()) {
|
||||
return database.query(new SelectListQuery<NPCID, Integer, NPCID, QNPC>(
|
||||
QNPC.npc, mapper.getIDMapper(QNPC.npc)) {
|
||||
@Override
|
||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||
}
|
||||
@@ -102,63 +103,18 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
||||
|
||||
@Override
|
||||
public int insertObjects(NPC... objects) {
|
||||
return database.query(new InsertQuery<NPC, QNPC, Object>(QNPC.npc,
|
||||
objects) {
|
||||
@Override
|
||||
protected void map(SQLInsertClause q, NPC o) {
|
||||
q.set(e.npcId, o.getID().getID())
|
||||
.set(e.npcTemplateId, o.getTemplateID().getID())
|
||||
.set(e.hp, o.getHP())
|
||||
.set(e.mp, o.getMP())
|
||||
.set(e.pointX,
|
||||
(o.getPoint() != null ? o.getPoint().getX()
|
||||
: null))
|
||||
.set(e.pointY,
|
||||
(o.getPoint() != null ? o.getPoint().getY()
|
||||
: null))
|
||||
.set(e.pointZ,
|
||||
(o.getPoint() != null ? o.getPoint().getZ()
|
||||
: null))
|
||||
.set(e.pointAngle,
|
||||
(o.getPoint() != null ? o.getPoint().getAngle()
|
||||
: null))
|
||||
|
||||
.set(e.respawnTime, o.getRespawnInterval());
|
||||
|
||||
}
|
||||
});
|
||||
return database.query(new InsertQuery<NPC, Integer, NPCID, QNPC>(
|
||||
QNPC.npc, mapper, objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateObjects(NPC... objects) {
|
||||
return database.query(new UpdateQuery<NPC, QNPC>(QNPC.npc, objects) {
|
||||
return database.query(new UpdateQuery<NPC, QNPC>(QNPC.npc, mapper,
|
||||
objects) {
|
||||
@Override
|
||||
protected void query(SQLUpdateClause q, NPC o) {
|
||||
q.where(e.npcId.eq(o.getID().getID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map(SQLUpdateClause q, NPC o) {
|
||||
q.set(e.npcId, o.getID().getID())
|
||||
.set(e.npcTemplateId, o.getTemplateID().getID())
|
||||
.set(e.hp, o.getHP())
|
||||
.set(e.mp, o.getMP())
|
||||
.set(e.pointX,
|
||||
(o.getPoint() != null ? o.getPoint().getX()
|
||||
: null))
|
||||
.set(e.pointY,
|
||||
(o.getPoint() != null ? o.getPoint().getY()
|
||||
: null))
|
||||
.set(e.pointZ,
|
||||
(o.getPoint() != null ? o.getPoint().getZ()
|
||||
: null))
|
||||
.set(e.pointAngle,
|
||||
(o.getPoint() != null ? o.getPoint().getAngle()
|
||||
: null))
|
||||
|
||||
.set(e.respawnTime, o.getRespawnInterval());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,24 +22,41 @@ import com.l2jserver.model.id.FriendID;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.provider.FriendIDProvider;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QCharacterFriend;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class CharacterFriendMapper implements
|
||||
Mapper<CharacterFriend, QCharacterFriend> {
|
||||
private final Mapper<FriendID, QCharacterFriend> idMapper = new Mapper<FriendID, QCharacterFriend>() {
|
||||
@Override
|
||||
public FriendID map(QCharacterFriend e, DatabaseRow row) {
|
||||
return idProvider.createID(
|
||||
charIdProvider.resolveID(row.get(e.characterId)),
|
||||
charIdProvider.resolveID(row.get(e.characterIdFriend)));
|
||||
}
|
||||
};
|
||||
public class CharacterFriendMapper extends
|
||||
AbstractMapper<CharacterFriend, FriendID, FriendID, QCharacterFriend> {
|
||||
// private final CompoundPrimaryKeyMapper<FriendID, CharacterID,
|
||||
// CharacterID, QCharacterFriend> idMapper = new
|
||||
// CompoundPrimaryKeyMapper<FriendID, CharacterID, CharacterID,
|
||||
// QCharacterFriend>() {
|
||||
// @Override
|
||||
// public AbstractCompoundID<CharacterID, CharacterID> raw(
|
||||
// QCharacterFriend entity, DatabaseRow row) {
|
||||
// return createID(entity, row);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public FriendID createID(QCharacterFriend entity, DatabaseRow row) {
|
||||
// return idProvider.createID(
|
||||
// charIdProvider.resolveID(row.get(e.characterId)),
|
||||
// charIdProvider.resolveID(row.get(e.characterIdFriend)));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public FriendID generated(
|
||||
// AbstractCompoundID<CharacterID, CharacterID> raw) {
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
|
||||
/**
|
||||
* The {@link CharacterID} provider
|
||||
@@ -64,13 +81,26 @@ public class CharacterFriendMapper implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharacterFriend map(QCharacterFriend e, DatabaseRow row) {
|
||||
public CharacterFriend select(QCharacterFriend e, DatabaseRow row) {
|
||||
return new CharacterFriend(idProvider.createID(
|
||||
charIdProvider.resolveID(row.get(e.characterId)),
|
||||
charIdProvider.resolveID(row.get(e.characterIdFriend))));
|
||||
}
|
||||
|
||||
public Mapper<FriendID, QCharacterFriend> getIDMapper() {
|
||||
return idMapper;
|
||||
@Override
|
||||
public void insert(QCharacterFriend e, CharacterFriend object,
|
||||
WritableDatabaseRow row) {
|
||||
row.set(e.characterId, object.getCharacterID().getID()).set(
|
||||
e.characterIdFriend, object.getFriendID().getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QCharacterFriend e, CharacterFriend object,
|
||||
WritableDatabaseRow row) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<FriendID, FriendID> getPrimaryKeyMapper() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,10 @@ import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
|
||||
import com.l2jserver.model.template.character.CharacterClass;
|
||||
import com.l2jserver.model.template.character.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QCharacter;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
@@ -37,11 +39,12 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class CharacterMapper implements Mapper<L2Character, QCharacter> {
|
||||
private final Mapper<CharacterID, QCharacter> idMapper = new Mapper<CharacterID, QCharacter>() {
|
||||
public class CharacterMapper extends
|
||||
AbstractMapper<L2Character, Integer, CharacterID, QCharacter> {
|
||||
private final PrimaryKeyMapper<CharacterID, Integer> pk = new PrimaryKeyMapper<CharacterID, Integer>() {
|
||||
@Override
|
||||
public CharacterID map(QCharacter e, DatabaseRow row) {
|
||||
return idProvider.resolveID(row.get(e.characterId));
|
||||
public CharacterID createID(Integer raw) {
|
||||
return idProvider.resolveID(raw);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,7 +87,7 @@ public class CharacterMapper implements Mapper<L2Character, QCharacter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Character map(QCharacter e, DatabaseRow row) {
|
||||
public L2Character select(QCharacter e, DatabaseRow row) {
|
||||
final CharacterClass charClass = row.get(e.characterClass);
|
||||
final CharacterTemplateID templateId = templateIdProvider
|
||||
.resolveID(charClass.id);
|
||||
@@ -123,7 +126,42 @@ public class CharacterMapper implements Mapper<L2Character, QCharacter> {
|
||||
return character;
|
||||
}
|
||||
|
||||
public Mapper<CharacterID, QCharacter> getIDMapper() {
|
||||
return idMapper;
|
||||
@Override
|
||||
public void insert(QCharacter e, L2Character object, WritableDatabaseRow row) {
|
||||
// same as update, reuse it
|
||||
update(e, object, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QCharacter e, L2Character object, WritableDatabaseRow row) {
|
||||
row.set(e.characterId, object.getID().getID())
|
||||
.set(e.accountId, object.getAccountID().getID())
|
||||
.set(e.clanId,
|
||||
(object.getClanID() != null ? object.getClanID()
|
||||
.getID() : null))
|
||||
.set(e.name, object.getName())
|
||||
.set(e.race, object.getRace())
|
||||
.set(e.characterClass, object.getCharacterClass())
|
||||
.set(e.sex, object.getSex())
|
||||
.set(e.level, object.getLevel())
|
||||
.set(e.experience, object.getExperience())
|
||||
.set(e.sp, object.getSP())
|
||||
.set(e.hp, object.getHP())
|
||||
.set(e.mp, object.getMP())
|
||||
.set(e.cp, object.getCP())
|
||||
.set(e.pointX, object.getPoint().getX())
|
||||
.set(e.pointY, object.getPoint().getY())
|
||||
.set(e.pointZ, object.getPoint().getZ())
|
||||
.set(e.pointAngle, object.getPoint().getAngle())
|
||||
.set(e.appearanceHairStyle,
|
||||
object.getAppearance().getHairStyle())
|
||||
.set(e.appearanceHairColor,
|
||||
object.getAppearance().getHairColor())
|
||||
.set(e.apperanceFace, object.getAppearance().getFace());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<CharacterID, Integer> getPrimaryKeyMapper() {
|
||||
return pk;
|
||||
}
|
||||
}
|
||||
@@ -25,20 +25,23 @@ import com.l2jserver.model.id.object.ItemID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.object.provider.ItemIDProvider;
|
||||
import com.l2jserver.model.id.provider.CharacterShortcutIDProvider;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QCharacterShortcut;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class CharacterShortcutMapper implements
|
||||
Mapper<CharacterShortcut, QCharacterShortcut> {
|
||||
private final Mapper<CharacterShortcutID, QCharacterShortcut> idMapper = new Mapper<CharacterShortcutID, QCharacterShortcut>() {
|
||||
public class CharacterShortcutMapper
|
||||
extends
|
||||
AbstractMapper<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut> {
|
||||
private final PrimaryKeyMapper<CharacterShortcutID, Integer> idMapper = new PrimaryKeyMapper<CharacterShortcutID, Integer>() {
|
||||
@Override
|
||||
public CharacterShortcutID map(QCharacterShortcut e, DatabaseRow row) {
|
||||
return idProvider.resolveID(row.get(e.shortcutId));
|
||||
public CharacterShortcutID createID(Integer raw) {
|
||||
return idProvider.resolveID(raw);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,7 +78,7 @@ public class CharacterShortcutMapper implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharacterShortcut map(QCharacterShortcut e, DatabaseRow row) {
|
||||
public CharacterShortcut select(QCharacterShortcut e, DatabaseRow row) {
|
||||
final CharacterShortcut shortcut = new CharacterShortcut();
|
||||
shortcut.setID(idProvider.resolveID(row.get(e.shortcutId)));
|
||||
final CharacterID charId = charIdProvider.resolveID(row
|
||||
@@ -98,7 +101,23 @@ public class CharacterShortcutMapper implements
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
public Mapper<CharacterShortcutID, QCharacterShortcut> getIDMapper() {
|
||||
@Override
|
||||
public void insert(QCharacterShortcut e, CharacterShortcut object,
|
||||
WritableDatabaseRow row) {
|
||||
update(e, object, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QCharacterShortcut e, CharacterShortcut object,
|
||||
WritableDatabaseRow row) {
|
||||
row.set(e.characterId, object.getID().getID())
|
||||
.set(e.type, object.getType())
|
||||
.set(e.objectId, object.getItemID().getID())
|
||||
.set(e.slot, object.getSlot()).set(e.page, object.getPage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<CharacterShortcutID, Integer> getPrimaryKeyMapper() {
|
||||
return idMapper;
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,22 @@ import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.provider.ChatMessageIDProvider;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QLogChat;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class ChatMessageMapper implements Mapper<ChatMessage, QLogChat> {
|
||||
private final Mapper<ChatMessageID, QLogChat> idMapper = new Mapper<ChatMessageID, QLogChat>() {
|
||||
public class ChatMessageMapper extends
|
||||
AbstractMapper<ChatMessage, Integer, ChatMessageID, QLogChat> {
|
||||
private final PrimaryKeyMapper<ChatMessageID, Integer> idMapper = new PrimaryKeyMapper<ChatMessageID, Integer>() {
|
||||
@Override
|
||||
public ChatMessageID map(QLogChat e, DatabaseRow row) {
|
||||
return idProvider.resolveID(row.get(e.messageId));
|
||||
public ChatMessageID createID(Integer raw) {
|
||||
return idMapper.createID(raw);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -63,7 +66,7 @@ public class ChatMessageMapper implements Mapper<ChatMessage, QLogChat> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatMessage map(QLogChat e, DatabaseRow row) {
|
||||
public ChatMessage select(QLogChat e, DatabaseRow row) {
|
||||
final ChatMessage message = new ChatMessage();
|
||||
message.setID(idProvider.resolveID(row.get(e.messageId)));
|
||||
|
||||
@@ -83,7 +86,28 @@ public class ChatMessageMapper implements Mapper<ChatMessage, QLogChat> {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Mapper<ChatMessageID, QLogChat> getIDMapper() {
|
||||
@Override
|
||||
public void insert(QLogChat e, ChatMessage onject, WritableDatabaseRow row) {
|
||||
row.set(e.type, onject.getType())
|
||||
.set(e.sender, onject.getSender().getID())
|
||||
.set(e.date, onject.getDate())
|
||||
.set(e.message, onject.getMessage());
|
||||
switch (onject.getType()) {
|
||||
case SHOUT:
|
||||
row.set(e.channelId, onject.getTarget().getID());
|
||||
break;
|
||||
default:
|
||||
row.set(e.channelId, onject.getChannelID());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QLogChat e, ChatMessage object, WritableDatabaseRow row) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<ChatMessageID, Integer> getPrimaryKeyMapper() {
|
||||
return idMapper;
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,21 @@ import com.l2jserver.model.id.object.ClanID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.object.provider.ClanIDProvider;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QClan;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class ClanMapper implements Mapper<Clan, QClan> {
|
||||
private final Mapper<ClanID, QClan> idMapper = new Mapper<ClanID, QClan>() {
|
||||
public class ClanMapper extends AbstractMapper<Clan, Integer, ClanID, QClan> {
|
||||
private final PrimaryKeyMapper<ClanID, Integer> idMapper = new PrimaryKeyMapper<ClanID, Integer>() {
|
||||
@Override
|
||||
public ClanID map(QClan e, DatabaseRow row) {
|
||||
return idProvider.resolveID(row.get(e.clanId));
|
||||
public ClanID createID(Integer raw) {
|
||||
return idProvider.resolveID(raw);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,14 +64,26 @@ public class ClanMapper implements Mapper<Clan, QClan> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clan map(QClan e, DatabaseRow row) {
|
||||
public Clan select(QClan e, DatabaseRow row) {
|
||||
final Clan clan = new Clan();
|
||||
clan.setID(idProvider.resolveID(row.get(e.clanId)));
|
||||
clan.setID(charIdProvider.resolveID(row.get(e.characterIdLeader)));
|
||||
return clan;
|
||||
}
|
||||
|
||||
public Mapper<ClanID, QClan> getIDMapper() {
|
||||
@Override
|
||||
public void insert(QClan e, Clan object, WritableDatabaseRow row) {
|
||||
update(e, object, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QClan e, Clan object, WritableDatabaseRow row) {
|
||||
row.set(e.clanId, object.getID().getID()).set(e.characterIdLeader,
|
||||
object.getLeaderID().getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<ClanID, Integer> getPrimaryKeyMapper() {
|
||||
return idMapper;
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,10 @@ import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||
import com.l2jserver.model.template.item.ItemTemplate;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QItem;
|
||||
import com.l2jserver.util.geometry.Coordinate;
|
||||
|
||||
@@ -38,16 +40,16 @@ import com.l2jserver.util.geometry.Coordinate;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class ItemMapper implements Mapper<Item, QItem> {
|
||||
public class ItemMapper extends AbstractMapper<Item, Integer, ItemID, QItem> {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Mapper<ItemID, QItem> idMapper = new Mapper<ItemID, QItem>() {
|
||||
private final PrimaryKeyMapper<ItemID, Integer> idMapper = new PrimaryKeyMapper<ItemID, Integer>() {
|
||||
@Override
|
||||
public ItemID map(QItem e, DatabaseRow row) {
|
||||
return idProvider.resolveID(row.get(e.itemId));
|
||||
public ItemID createID(Integer raw) {
|
||||
return idProvider.resolveID(raw);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,7 +85,7 @@ public class ItemMapper implements Mapper<Item, QItem> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item map(QItem e, DatabaseRow row) {
|
||||
public Item select(QItem e, DatabaseRow row) {
|
||||
final ItemID id = idProvider.resolveID(row.get(e.itemId));
|
||||
final ItemTemplateID templateId = templateIdProvider.resolveID(row
|
||||
.get(e.templateId));
|
||||
@@ -113,7 +115,34 @@ public class ItemMapper implements Mapper<Item, QItem> {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Mapper<ItemID, QItem> getIDMapper() {
|
||||
@Override
|
||||
public void insert(QItem e, Item object, WritableDatabaseRow row) {
|
||||
update(e, object, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QItem e, Item object, WritableDatabaseRow row) {
|
||||
row.set(e.itemId, object.getID().getID())
|
||||
.set(e.templateId, object.getTemplateID().getID())
|
||||
.set(e.characterId,
|
||||
(object.getOwnerID() != null ? object.getOwnerID()
|
||||
.getID() : null))
|
||||
.set(e.location, object.getLocation())
|
||||
.set(e.paperdoll, object.getPaperdoll())
|
||||
.set(e.count, object.getCount())
|
||||
.set(e.coordX,
|
||||
(object.getPoint() != null ? object.getPoint().getX()
|
||||
: null))
|
||||
.set(e.coordY,
|
||||
(object.getPoint() != null ? object.getPoint().getY()
|
||||
: null))
|
||||
.set(e.coordZ,
|
||||
(object.getPoint() != null ? object.getPoint().getZ()
|
||||
: null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<ItemID, Integer> getPrimaryKeyMapper() {
|
||||
return idMapper;
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,10 @@ import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
|
||||
import com.l2jserver.model.template.npc.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.database.dao.AbstractMapper;
|
||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
||||
import com.l2jserver.service.database.dao.Mapper;
|
||||
import com.l2jserver.service.database.dao.PrimaryKeyMapper;
|
||||
import com.l2jserver.service.database.dao.WritableDatabaseRow;
|
||||
import com.l2jserver.service.database.model.QNPC;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
@@ -35,16 +37,16 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class NPCMapper implements Mapper<NPC, QNPC> {
|
||||
public class NPCMapper extends AbstractMapper<NPC, Integer, NPCID, QNPC> {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Mapper<NPCID, QNPC> idMapper = new Mapper<NPCID, QNPC>() {
|
||||
private final PrimaryKeyMapper<NPCID, Integer> idMapper = new PrimaryKeyMapper<NPCID, Integer>() {
|
||||
@Override
|
||||
public NPCID map(QNPC e, DatabaseRow row) {
|
||||
return idProvider.resolveID(row.get(e.npcId));
|
||||
public NPCID createID(Integer raw) {
|
||||
return idProvider.resolveID(raw);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -71,7 +73,7 @@ public class NPCMapper implements Mapper<NPC, QNPC> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC map(QNPC e, DatabaseRow row) {
|
||||
public NPC select(QNPC e, DatabaseRow row) {
|
||||
final NPCID id = idProvider.resolveID(row.get(e.npcId));
|
||||
NPCTemplateID templateId = templateIdProvider.resolveID(row
|
||||
.get(e.npcTemplateId));
|
||||
@@ -99,7 +101,35 @@ public class NPCMapper implements Mapper<NPC, QNPC> {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public Mapper<NPCID, QNPC> getIDMapper() {
|
||||
@Override
|
||||
public void insert(QNPC e, NPC object, WritableDatabaseRow row) {
|
||||
update(e, object, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QNPC e, NPC object, WritableDatabaseRow row) {
|
||||
row.set(e.npcId, object.getID().getID())
|
||||
.set(e.npcTemplateId, object.getTemplateID().getID())
|
||||
.set(e.hp, object.getHP())
|
||||
.set(e.mp, object.getMP())
|
||||
.set(e.pointX,
|
||||
(object.getPoint() != null ? object.getPoint().getX()
|
||||
: null))
|
||||
.set(e.pointY,
|
||||
(object.getPoint() != null ? object.getPoint().getY()
|
||||
: null))
|
||||
.set(e.pointZ,
|
||||
(object.getPoint() != null ? object.getPoint().getZ()
|
||||
: null))
|
||||
.set(e.pointAngle,
|
||||
(object.getPoint() != null ? object.getPoint()
|
||||
.getAngle() : null))
|
||||
|
||||
.set(e.respawnTime, object.getRespawnInterval());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryKeyMapper<NPCID, Integer> getPrimaryKeyMapper() {
|
||||
return idMapper;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.l2jserver.model.template.actor.ActorSex;
|
||||
import com.l2jserver.model.template.character.CharacterClass;
|
||||
import com.l2jserver.model.template.character.CharacterRace;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterFace;
|
||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairColor;
|
||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairStyle;
|
||||
@@ -26,7 +25,7 @@ import com.mysema.query.types.path.StringPath;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QCharacter extends RelationalPathBase<L2Character> {
|
||||
public class QCharacter extends RelationalPathBase<Integer> {
|
||||
private static final long serialVersionUID = -59499032;
|
||||
|
||||
public static final QCharacter character = new QCharacter("l2character");
|
||||
@@ -82,19 +81,19 @@ public class QCharacter extends RelationalPathBase<L2Character> {
|
||||
public final EnumPath<CharacterFace> apperanceFace = createEnum(
|
||||
"apperance_face", CharacterFace.class);
|
||||
|
||||
public final PrimaryKey<L2Character> primary = createPrimaryKey(characterId);
|
||||
public final PrimaryKey<Integer> primary = createPrimaryKey(characterId);
|
||||
public final ForeignKey<Clan> clanIdKey = createForeignKey(clanId, "");
|
||||
|
||||
public QCharacter(String variable) {
|
||||
super(L2Character.class, forVariable(variable), "null", "character");
|
||||
super(Integer.class, forVariable(variable), "null", "character");
|
||||
}
|
||||
|
||||
public QCharacter(Path<? extends L2Character> entity) {
|
||||
public QCharacter(Path<? extends Integer> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null", "character");
|
||||
}
|
||||
|
||||
public QCharacter(PathMetadata<?> metadata) {
|
||||
super(L2Character.class, metadata, "null", "character");
|
||||
super(Integer.class, metadata, "null", "character");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.l2jserver.service.database.model;
|
||||
|
||||
import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
import com.l2jserver.model.game.CharacterFriend;
|
||||
import com.l2jserver.model.id.FriendID;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||
import com.mysema.query.sql.PrimaryKey;
|
||||
import com.mysema.query.types.Path;
|
||||
@@ -15,7 +15,7 @@ import com.mysema.query.types.path.NumberPath;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QCharacterFriend extends
|
||||
com.mysema.query.sql.RelationalPathBase<CharacterFriend> {
|
||||
com.mysema.query.sql.RelationalPathBase<FriendID> {
|
||||
private static final long serialVersionUID = 1488651942;
|
||||
|
||||
public static final QCharacterFriend characterFriend = new QCharacterFriend(
|
||||
@@ -28,21 +28,20 @@ public class QCharacterFriend extends
|
||||
public final NumberPath<Integer> characterIdFriend = createNumber(
|
||||
"character_id_friend", Integer.class);
|
||||
|
||||
public final PrimaryKey<CharacterFriend> primary = createPrimaryKey(
|
||||
characterId, characterIdFriend);
|
||||
public final PrimaryKey<FriendID> primary = createPrimaryKey(characterId,
|
||||
characterIdFriend);
|
||||
|
||||
public QCharacterFriend(String variable) {
|
||||
super(CharacterFriend.class, forVariable(variable), "null",
|
||||
"character_friend");
|
||||
super(FriendID.class, forVariable(variable), "null", "character_friend");
|
||||
}
|
||||
|
||||
public QCharacterFriend(Path<? extends CharacterFriend> entity) {
|
||||
public QCharacterFriend(Path<? extends FriendID> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null",
|
||||
"character_friend");
|
||||
}
|
||||
|
||||
public QCharacterFriend(PathMetadata<?> metadata) {
|
||||
super(CharacterFriend.class, metadata, "null", "character_friend");
|
||||
super(FriendID.class, metadata, "null", "character_friend");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.l2jserver.service.database.model;
|
||||
|
||||
import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
import com.l2jserver.model.game.CharacterShortcut;
|
||||
import com.l2jserver.model.game.CharacterShortcut.ShortcutType;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnAutoIncrement;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnNullable;
|
||||
@@ -19,7 +18,7 @@ import com.mysema.query.types.path.NumberPath;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QCharacterShortcut extends
|
||||
com.mysema.query.sql.RelationalPathBase<CharacterShortcut> {
|
||||
com.mysema.query.sql.RelationalPathBase<Integer> {
|
||||
private static final long serialVersionUID = 1450964558;
|
||||
|
||||
public static final QCharacterShortcut characterShortcut = new QCharacterShortcut(
|
||||
@@ -52,20 +51,20 @@ public class QCharacterShortcut extends
|
||||
public final EnumPath<ShortcutType> type = createEnum("type",
|
||||
ShortcutType.class);
|
||||
|
||||
public final PrimaryKey<CharacterShortcut> primary = createPrimaryKey(shortcutId);
|
||||
public final PrimaryKey<Integer> primary = createPrimaryKey(shortcutId);
|
||||
|
||||
public QCharacterShortcut(String variable) {
|
||||
super(CharacterShortcut.class, forVariable(variable), "null",
|
||||
super(Integer.class, forVariable(variable), "null",
|
||||
"character_shortcut");
|
||||
}
|
||||
|
||||
public QCharacterShortcut(Path<? extends CharacterShortcut> entity) {
|
||||
public QCharacterShortcut(Path<? extends Integer> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null",
|
||||
"character_shortcut");
|
||||
}
|
||||
|
||||
public QCharacterShortcut(PathMetadata<?> metadata) {
|
||||
super(CharacterShortcut.class, metadata, "null", "character_shortcut");
|
||||
super(Integer.class, metadata, "null", "character_shortcut");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.l2jserver.service.database.model;
|
||||
|
||||
import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||
import com.mysema.query.sql.PrimaryKey;
|
||||
import com.mysema.query.types.Path;
|
||||
@@ -14,7 +13,7 @@ import com.mysema.query.types.path.NumberPath;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QClan extends com.mysema.query.sql.RelationalPathBase<Clan> {
|
||||
public class QClan extends com.mysema.query.sql.RelationalPathBase<Integer> {
|
||||
private static final long serialVersionUID = 1592083511;
|
||||
|
||||
public static final QClan clan = new QClan("clan");
|
||||
@@ -26,18 +25,18 @@ public class QClan extends com.mysema.query.sql.RelationalPathBase<Clan> {
|
||||
public final NumberPath<Integer> characterIdLeader = createNumber(
|
||||
"character_id_leader", Integer.class);
|
||||
|
||||
public final PrimaryKey<Clan> primary = createPrimaryKey(clanId);
|
||||
public final PrimaryKey<Integer> primary = createPrimaryKey(clanId);
|
||||
|
||||
public QClan(String variable) {
|
||||
super(Clan.class, forVariable(variable), "null", "clan");
|
||||
super(Integer.class, forVariable(variable), "null", "clan");
|
||||
}
|
||||
|
||||
public QClan(Path<? extends Clan> entity) {
|
||||
public QClan(Path<? extends Integer> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null", "clan");
|
||||
}
|
||||
|
||||
public QClan(PathMetadata<?> metadata) {
|
||||
super(Clan.class, metadata, "null", "clan");
|
||||
super(Integer.class, metadata, "null", "clan");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.l2jserver.service.database.model;
|
||||
|
||||
import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.ItemLocation;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnDefault;
|
||||
@@ -19,7 +18,7 @@ import com.mysema.query.types.path.NumberPath;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QItem extends com.mysema.query.sql.RelationalPathBase<Item> {
|
||||
public class QItem extends com.mysema.query.sql.RelationalPathBase<Integer> {
|
||||
private static final long serialVersionUID = 1592270068;
|
||||
|
||||
public static final QItem item = new QItem("item");
|
||||
@@ -58,18 +57,18 @@ public class QItem extends com.mysema.query.sql.RelationalPathBase<Item> {
|
||||
public final EnumPath<InventoryPaperdoll> paperdoll = createEnum(
|
||||
"paperdoll", InventoryPaperdoll.class);
|
||||
|
||||
public final PrimaryKey<Item> primary = createPrimaryKey(itemId);
|
||||
public final PrimaryKey<Integer> primary = createPrimaryKey(itemId);
|
||||
|
||||
public QItem(String variable) {
|
||||
super(Item.class, forVariable(variable), "null", "item");
|
||||
super(Integer.class, forVariable(variable), "null", "item");
|
||||
}
|
||||
|
||||
public QItem(Path<? extends Item> entity) {
|
||||
public QItem(Path<? extends Integer> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null", "item");
|
||||
}
|
||||
|
||||
public QItem(PathMetadata<?> metadata) {
|
||||
super(Item.class, metadata, "null", "item");
|
||||
super(Integer.class, metadata, "null", "item");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnAutoIncrement;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnNullable;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||
@@ -22,7 +21,7 @@ import com.mysema.query.types.path.StringPath;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QLogChat extends com.mysema.query.sql.RelationalPathBase<ChatMessage> {
|
||||
public class QLogChat extends com.mysema.query.sql.RelationalPathBase<Integer> {
|
||||
private static final long serialVersionUID = -76124357;
|
||||
|
||||
public static final QLogChat logChat = new QLogChat("log_chat");
|
||||
@@ -49,18 +48,18 @@ public class QLogChat extends com.mysema.query.sql.RelationalPathBase<ChatMessag
|
||||
public final EnumPath<ChatMessageType> type = createEnum("type",
|
||||
ChatMessageType.class);
|
||||
|
||||
public final PrimaryKey<ChatMessage> primary = createPrimaryKey(messageId);
|
||||
public final PrimaryKey<Integer> primary = createPrimaryKey(messageId);
|
||||
|
||||
public QLogChat(String variable) {
|
||||
super(ChatMessage.class, forVariable(variable), "null", "log_chat");
|
||||
super(Integer.class, forVariable(variable), "null", "log_chat");
|
||||
}
|
||||
|
||||
public QLogChat(Path<? extends ChatMessage> entity) {
|
||||
public QLogChat(Path<? extends Integer> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null", "log_chat");
|
||||
}
|
||||
|
||||
public QLogChat(PathMetadata<?> metadata) {
|
||||
super(ChatMessage.class, metadata, "null", "log_chat");
|
||||
super(Integer.class, metadata, "null", "log_chat");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.l2jserver.service.database.model;
|
||||
|
||||
import static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||
import com.mysema.query.sql.PrimaryKey;
|
||||
import com.mysema.query.types.Path;
|
||||
@@ -14,7 +13,7 @@ import com.mysema.query.types.path.NumberPath;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class QNPC extends com.mysema.query.sql.RelationalPathBase<NPC> {
|
||||
public class QNPC extends com.mysema.query.sql.RelationalPathBase<Integer> {
|
||||
private static final long serialVersionUID = 2129578208;
|
||||
|
||||
public static final QNPC npc = new QNPC("npc");
|
||||
@@ -29,8 +28,6 @@ public class QNPC extends com.mysema.query.sql.RelationalPathBase<NPC> {
|
||||
public final NumberPath<Double> hp = createNumber("hp", Double.class);
|
||||
public final NumberPath<Double> mp = createNumber("mp", Double.class);
|
||||
|
||||
public final NumberPath<Double> pointAngle = createNumber("point_angle",
|
||||
Double.class);
|
||||
@ColumnSize(10)
|
||||
public final NumberPath<Integer> pointX = createNumber("point_x",
|
||||
Integer.class);
|
||||
@@ -40,23 +37,25 @@ public class QNPC extends com.mysema.query.sql.RelationalPathBase<NPC> {
|
||||
@ColumnSize(10)
|
||||
public final NumberPath<Integer> pointZ = createNumber("point_z",
|
||||
Integer.class);
|
||||
public final NumberPath<Double> pointAngle = createNumber("point_angle",
|
||||
Double.class);
|
||||
|
||||
@ColumnSize(8)
|
||||
public final NumberPath<Long> respawnTime = createNumber("respawn_time",
|
||||
Long.class);
|
||||
|
||||
public final PrimaryKey<NPC> primary = createPrimaryKey(npcId);
|
||||
public final PrimaryKey<Integer> primary = createPrimaryKey(npcId);
|
||||
|
||||
public QNPC(String variable) {
|
||||
super(NPC.class, forVariable(variable), "null", "npc");
|
||||
super(Integer.class, forVariable(variable), "null", "npc");
|
||||
}
|
||||
|
||||
public QNPC(Path<? extends NPC> entity) {
|
||||
public QNPC(Path<? extends Integer> entity) {
|
||||
super(entity.getType(), entity.getMetadata(), "null", "npc");
|
||||
}
|
||||
|
||||
public QNPC(PathMetadata<?> metadata) {
|
||||
super(NPC.class, metadata, "null", "npc");
|
||||
super(Integer.class, metadata, "null", "npc");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user