mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface DatabaseRow {
|
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);
|
<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);
|
<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;
|
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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
* @param <O>
|
* @param <I>
|
||||||
* the object type returned by this mapper
|
* the object type returned by this mapper
|
||||||
* @param <E>
|
* @param <R>
|
||||||
* the entity type
|
* the ID raw type
|
||||||
*/
|
*/
|
||||||
public interface Mapper<O, E extends RelationalPathBase<?>> {
|
public interface PrimaryKeyMapper<I extends ID<? super R>, R> {
|
||||||
O map(E entity, DatabaseRow row);
|
/**
|
||||||
|
* 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.DatabaseException;
|
||||||
import com.l2jserver.service.database.DatabaseService;
|
import com.l2jserver.service.database.DatabaseService;
|
||||||
import com.l2jserver.service.database.dao.DatabaseRow;
|
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.QueryFactory;
|
||||||
import com.l2jserver.service.database.sql.ddl.TableFactory;
|
import com.l2jserver.service.database.sql.ddl.TableFactory;
|
||||||
import com.l2jserver.service.database.sql.ddl.struct.Table;
|
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.RelationalPathBase;
|
||||||
import com.mysema.query.sql.SQLQueryFactory;
|
import com.mysema.query.sql.SQLQueryFactory;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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.dml.SQLUpdateClause;
|
||||||
import com.mysema.query.sql.types.Type;
|
import com.mysema.query.sql.types.Type;
|
||||||
import com.mysema.query.types.Path;
|
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
|
* you do need low level access, feel free to use the {@link Query} class
|
||||||
* directly.
|
* 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}.
|
* {@link Object}.
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -237,7 +238,7 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
*/
|
*/
|
||||||
@ConfigurationPropertyGetter(defaultValue = "true")
|
@ConfigurationPropertyGetter(defaultValue = "true")
|
||||||
@ConfigurationXPath("/configuration/services/database/jdbc/updateSchema")
|
@ConfigurationXPath("/configuration/services/database/jdbc/updateSchema")
|
||||||
String getUpdateSchema();
|
boolean getUpdateSchema();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param updateSchema
|
* @param updateSchema
|
||||||
@@ -245,7 +246,7 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
*/
|
*/
|
||||||
@ConfigurationPropertySetter
|
@ConfigurationPropertySetter
|
||||||
@ConfigurationXPath("/configuration/services/database/jdbc/updateSchema")
|
@ConfigurationXPath("/configuration/services/database/jdbc/updateSchema")
|
||||||
void setUpdateSchema(String updateSchema);
|
void setUpdateSchema(boolean updateSchema);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the maximum number of active connections
|
* @return the maximum number of active connections
|
||||||
@@ -345,16 +346,18 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
true);
|
true);
|
||||||
dataSource = new PoolingDataSource(connectionPool);
|
dataSource = new PoolingDataSource(connectionPool);
|
||||||
|
|
||||||
try {
|
if (config.getUpdateSchema()) {
|
||||||
final Connection conn = dataSource.getConnection();
|
|
||||||
try {
|
try {
|
||||||
ensureDatabaseSchema(conn);
|
final Connection conn = dataSource.getConnection();
|
||||||
} finally {
|
try {
|
||||||
conn.close();
|
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) {
|
for (final Type<?> type : sqlTypes) {
|
||||||
@@ -570,7 +573,8 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return query.query(engine.createSQLQueryFactory(conn));
|
return query
|
||||||
|
.query(engine.createSQLQueryFactory(conn), this);
|
||||||
} finally {
|
} finally {
|
||||||
if (!inTransaction) {
|
if (!inTransaction) {
|
||||||
conn.commit();
|
conn.commit();
|
||||||
@@ -659,9 +663,12 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
*
|
*
|
||||||
* @param factory
|
* @param factory
|
||||||
* the query factory (database specific)
|
* the query factory (database specific)
|
||||||
|
* @param database
|
||||||
|
* the database service instance
|
||||||
* @return the query return value
|
* @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> {
|
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> {
|
extends AbstractQuery<Integer> {
|
||||||
|
private final InsertMapper<O, RI, I, E> mapper;
|
||||||
private final Iterator<O> iterator;
|
private final Iterator<O> iterator;
|
||||||
private final Path<K> primaryKey;
|
private final Path<RI> primaryKey;
|
||||||
|
|
||||||
protected final E e;
|
protected final E e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity type
|
* the entity type
|
||||||
|
* @param mapper
|
||||||
|
* the insert mapper
|
||||||
* @param iterator
|
* @param iterator
|
||||||
* the objects to be inserted
|
* the objects to be inserted
|
||||||
* @param primaryKey
|
* @param primaryKey
|
||||||
* the primary key, if any. Only required if the ID is
|
* the primary key, if any. Only required if the ID is
|
||||||
* generated by the database engine.
|
* 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.iterator = iterator;
|
||||||
|
this.mapper = mapper;
|
||||||
this.e = entity;
|
this.e = entity;
|
||||||
this.primaryKey = primaryKey;
|
this.primaryKey = primaryKey;
|
||||||
}
|
}
|
||||||
@@ -699,27 +711,35 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity type
|
* the entity type
|
||||||
|
* @param mapper
|
||||||
|
* the insert mapper
|
||||||
* @param iterator
|
* @param iterator
|
||||||
* the objects to be inserted
|
* the objects to be inserted
|
||||||
*/
|
*/
|
||||||
public InsertQuery(E entity, Iterator<O> iterator) {
|
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||||
this(entity, null, iterator);
|
Iterator<O> iterator) {
|
||||||
|
this(entity, mapper, null, iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity type
|
* the entity type
|
||||||
|
* @param mapper
|
||||||
|
* the insert mapper
|
||||||
* @param objects
|
* @param objects
|
||||||
* the objects to be inserted
|
* the objects to be inserted
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public InsertQuery(E entity, O... objects) {
|
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||||
this(entity, null, Iterators.forArray(objects));
|
O... objects) {
|
||||||
|
this(entity, mapper, null, Iterators.forArray(objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity type
|
* the entity type
|
||||||
|
* @param mapper
|
||||||
|
* the insert mapper
|
||||||
* @param objects
|
* @param objects
|
||||||
* the objects to be inserted
|
* the objects to be inserted
|
||||||
* @param primaryKey
|
* @param primaryKey
|
||||||
@@ -727,25 +747,31 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
* generated by the database engine.
|
* generated by the database engine.
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public InsertQuery(E entity, Path<K> primaryKey, O... objects) {
|
public InsertQuery(E entity, InsertMapper<O, RI, I, E> mapper,
|
||||||
this(entity, primaryKey, Iterators.forArray(objects));
|
Path<RI> primaryKey, O... objects) {
|
||||||
|
this(entity, mapper, primaryKey, Iterators.forArray(objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public final Integer query(
|
public final Integer query(
|
||||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||||
|
DatabaseService database) {
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final O object = iterator.next();
|
final O object = iterator.next();
|
||||||
final SQLInsertClause insert = factory.insert(e);
|
final SQLInsertWritableDatabaseRow row = new SQLInsertWritableDatabaseRow(
|
||||||
// maps query to the values
|
factory.insert(e));
|
||||||
map(insert, object);
|
mapper.insert(e, object, row);
|
||||||
|
|
||||||
if (primaryKey == null) {
|
if (primaryKey == null) {
|
||||||
insert.execute();
|
row.getClause().execute();
|
||||||
} else {
|
} else {
|
||||||
final K key = insert.executeWithKey(primaryKey);
|
final RI key = row.getClause().executeWithKey(primaryKey);
|
||||||
key(key, object);
|
final I id = mapper.getPrimaryKeyMapper().createID(key);
|
||||||
|
if (object instanceof Model) {
|
||||||
|
((Model<I>) object).setID(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rows++;
|
rows++;
|
||||||
|
|
||||||
@@ -753,52 +779,56 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
}
|
}
|
||||||
return rows;
|
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<?>>
|
public static abstract class UpdateQuery<O, E extends RelationalPathBase<?>>
|
||||||
extends AbstractQuery<Integer> {
|
extends AbstractQuery<Integer> {
|
||||||
|
private final UpdateMapper<O, E> mapper;
|
||||||
private final Iterator<O> iterator;
|
private final Iterator<O> iterator;
|
||||||
protected final E e;
|
protected final E e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity type
|
* the entity type
|
||||||
|
* @param mapper
|
||||||
|
* the update mapper
|
||||||
* @param iterator
|
* @param iterator
|
||||||
* the objects to be inserted
|
* 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.iterator = iterator;
|
||||||
|
this.mapper = mapper;
|
||||||
this.e = entity;
|
this.e = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity type
|
* the entity type
|
||||||
|
* @param mapper
|
||||||
|
* the update mapper
|
||||||
* @param objects
|
* @param objects
|
||||||
* the objects to be inserted
|
* the objects to be inserted
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public UpdateQuery(E entity, O... objects) {
|
public UpdateQuery(E entity, UpdateMapper<O, E> mapper, O... objects) {
|
||||||
this(entity, Iterators.forArray(objects));
|
this(entity, mapper, Iterators.forArray(objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Integer query(
|
public final Integer query(
|
||||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||||
|
DatabaseService database) {
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final O object = iterator.next();
|
final O object = iterator.next();
|
||||||
final SQLUpdateClause update = factory.update(e);
|
final SQLUpdateWritableDatabaseRow row = new SQLUpdateWritableDatabaseRow(
|
||||||
|
factory.update(e));
|
||||||
// maps query to the values
|
// maps query to the values
|
||||||
query(update, object);
|
query(row.getClause(), object);
|
||||||
map(update, object);
|
mapper.update(e, object, row);
|
||||||
|
|
||||||
rows += update.execute();
|
rows += row.getClause().execute();
|
||||||
|
|
||||||
updateDesire(object, ObjectDesire.UPDATE);
|
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 query(SQLUpdateClause q, O o);
|
||||||
|
|
||||||
protected abstract void map(SQLUpdateClause q, O o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class DeleteQuery<O, E extends RelationalPathBase<?>>
|
public static abstract class DeleteQuery<O, E extends RelationalPathBase<?>>
|
||||||
@@ -839,7 +867,8 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Integer query(
|
public final Integer query(
|
||||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||||
|
DatabaseService database) {
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final O object = iterator.next();
|
final O object = iterator.next();
|
||||||
@@ -857,10 +886,10 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
protected abstract void query(SQLDeleteClause q, O o);
|
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> {
|
extends AbstractQuery<R> {
|
||||||
protected final E entity;
|
protected final E entity;
|
||||||
protected final Mapper<O, E> mapper;
|
protected final SelectMapper<O, RI, I, E> mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
@@ -868,70 +897,107 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
* @param mapper
|
* @param mapper
|
||||||
* the object 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.entity = entity;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final R query(
|
public final R query(
|
||||||
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory) {
|
SQLQueryFactory<? extends AbstractSQLQuery<?>, ?, ?, ?, ?, ?> factory,
|
||||||
|
DatabaseService database) {
|
||||||
final AbstractSQLQuery<?> select = factory.query();
|
final AbstractSQLQuery<?> select = factory.query();
|
||||||
// maps query to the values
|
// maps query to the values
|
||||||
select.from(entity);
|
select.from(entity);
|
||||||
query(select, entity);
|
query(select, entity);
|
||||||
return perform(select);
|
return perform(select, database);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void query(AbstractSQLQuery<?> q, E e);
|
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<?>>
|
public static abstract class SelectSingleQuery<O, RI, I extends ID<? super RI>, E extends RelationalPathBase<RI>>
|
||||||
extends AbstractSelectQuery<O, O, E> {
|
extends AbstractSelectQuery<O, O, RI, I, E> {
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity
|
* the entity
|
||||||
* @param mapper
|
* @param mapper
|
||||||
* the mapper
|
* the mapper
|
||||||
*/
|
*/
|
||||||
public SelectSingleQuery(E entity, Mapper<O, E> mapper) {
|
public SelectSingleQuery(E entity, SelectMapper<O, RI, I, E> mapper) {
|
||||||
super(entity, mapper);
|
super(entity, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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());
|
final List<Object[]> results = select.limit(1).list(entity.all());
|
||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
return mapper.map(entity, new SQLDatabaseRow(results.get(0),
|
final DatabaseRow row = new SQLDatabaseRow(results.get(0),
|
||||||
entity));
|
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 {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class SelectListQuery<O, E extends RelationalPathBase<?>>
|
public static abstract class SelectListQuery<O, RI, I extends ID<? super RI>, E extends RelationalPathBase<RI>>
|
||||||
extends AbstractSelectQuery<List<O>, O, E> {
|
extends AbstractSelectQuery<List<O>, O, RI, I, E> {
|
||||||
/**
|
/**
|
||||||
* @param entity
|
* @param entity
|
||||||
* the entity
|
* the entity
|
||||||
* @param mapper
|
* @param mapper
|
||||||
* the mapper
|
* the mapper
|
||||||
*/
|
*/
|
||||||
public SelectListQuery(E entity, Mapper<O, E> mapper) {
|
public SelectListQuery(E entity, SelectMapper<O, RI, I, E> mapper) {
|
||||||
super(entity, mapper);
|
super(entity, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 List<Object[]> results = select.list(entity.all());
|
||||||
final SQLDatabaseRow row = new SQLDatabaseRow(entity);
|
final SQLDatabaseRow row = new SQLDatabaseRow(entity);
|
||||||
final List<O> objects = CollectionFactory.newList();
|
final List<O> objects = CollectionFactory.newList();
|
||||||
for (final Object[] data : results) {
|
for (final Object[] data : results) {
|
||||||
row.setRow(data);
|
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)
|
if (object != null)
|
||||||
objects.add(object);
|
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>
|
<database>
|
||||||
<jdbc>
|
<jdbc>
|
||||||
<!-- Defines the connection URL used by JDBC to connect to the database. -->
|
<!-- 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. -->
|
<!-- 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
|
<!-- 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
|
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.ClanDAO;
|
||||||
import com.l2jserver.model.dao.ItemDAO;
|
import com.l2jserver.model.dao.ItemDAO;
|
||||||
import com.l2jserver.model.dao.NPCDAO;
|
import com.l2jserver.model.dao.NPCDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLCharacterDAO;
|
import com.l2jserver.service.database.dao.sql.SQLCharacterDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLCharacterFriendDAO;
|
import com.l2jserver.service.database.dao.sql.SQLCharacterFriendDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLCharacterShortcutDAO;
|
import com.l2jserver.service.database.dao.sql.SQLCharacterShortcutDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLChatMessageDAO;
|
import com.l2jserver.service.database.dao.sql.SQLChatMessageDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLClanDAO;
|
import com.l2jserver.service.database.dao.sql.SQLClanDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLItemDAO;
|
import com.l2jserver.service.database.dao.sql.SQLItemDAO;
|
||||||
import com.l2jserver.service.database.sql.SQLNPCDAO;
|
import com.l2jserver.service.database.dao.sql.SQLNPCDAO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Google Guice {@link Module} for JDBC DAOs
|
* Google Guice {@link Module} for JDBC DAOs
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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;
|
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.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||||
import com.mysema.query.sql.AbstractSQLQuery;
|
import com.mysema.query.sql.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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.dml.SQLUpdateClause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,127 +64,82 @@ public class SQLCharacterDAO extends AbstractSQLDAO<L2Character, CharacterID>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public L2Character select(final CharacterID id) {
|
public L2Character select(final CharacterID id) {
|
||||||
return database.query(new SelectSingleQuery<L2Character, QCharacter>(
|
return database
|
||||||
QCharacter.character, mapper) {
|
.query(new SelectSingleQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||||
@Override
|
QCharacter.character, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
@Override
|
||||||
q.where(e.characterId.eq(id.getID()));
|
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||||
}
|
q.where(e.characterId.eq(id.getID()));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(final Clan clan) {
|
public void load(final Clan clan) {
|
||||||
clan.getMembers().load(database.query(new SelectListQuery<CharacterID, QCharacter>(
|
clan.getMembers()
|
||||||
QCharacter.character, mapper.getIDMapper()) {
|
.load(database
|
||||||
@Override
|
.query(new SelectListQuery<CharacterID, Integer, CharacterID, QCharacter>(
|
||||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
QCharacter.character, mapper
|
||||||
q.where(e.clanId.eq(clan.getID().getID()));
|
.getIDMapper(QCharacter.character)) {
|
||||||
}
|
@Override
|
||||||
}));
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
|
QCharacter e) {
|
||||||
|
q.where(e.clanId.eq(clan.getID().getID()));
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public L2Character selectByName(final String name) {
|
public L2Character selectByName(final String name) {
|
||||||
return database.query(new SelectSingleQuery<L2Character, QCharacter>(
|
return database
|
||||||
QCharacter.character, mapper) {
|
.query(new SelectSingleQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||||
@Override
|
QCharacter.character, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
@Override
|
||||||
q.where(e.name.eq(name));
|
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||||
}
|
q.where(e.name.eq(name));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<L2Character> selectByAccount(final AccountID account) {
|
public List<L2Character> selectByAccount(final AccountID account) {
|
||||||
return database.query(new SelectListQuery<L2Character, QCharacter>(
|
return database
|
||||||
QCharacter.character, mapper) {
|
.query(new SelectListQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||||
@Override
|
QCharacter.character, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
@Override
|
||||||
q.where(e.accountId.eq(account.getID()));
|
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||||
}
|
q.where(e.accountId.eq(account.getID()));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CharacterID> selectIDs() {
|
public List<CharacterID> selectIDs() {
|
||||||
return database.query(new SelectListQuery<CharacterID, QCharacter>(
|
return database
|
||||||
QCharacter.character, mapper.getIDMapper()) {
|
.query(new SelectListQuery<CharacterID, Integer, CharacterID, QCharacter>(
|
||||||
@Override
|
QCharacter.character, mapper
|
||||||
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
.getIDMapper(QCharacter.character)) {
|
||||||
}
|
@Override
|
||||||
});
|
protected void query(AbstractSQLQuery<?> q, QCharacter e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertObjects(L2Character... characters) {
|
public int insertObjects(L2Character... characters) {
|
||||||
return database.query(new InsertQuery<L2Character, QCharacter, Object>(
|
return database
|
||||||
QCharacter.character, characters) {
|
.query(new InsertQuery<L2Character, Integer, CharacterID, QCharacter>(
|
||||||
@Override
|
QCharacter.character, mapper, characters));
|
||||||
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());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateObjects(L2Character... characters) {
|
public int updateObjects(L2Character... characters) {
|
||||||
return database.query(new UpdateQuery<L2Character, QCharacter>(
|
return database.query(new UpdateQuery<L2Character, QCharacter>(
|
||||||
QCharacter.character, characters) {
|
QCharacter.character, mapper, characters) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(SQLUpdateClause q, L2Character o) {
|
protected void query(SQLUpdateClause q, L2Character o) {
|
||||||
q.where(e.characterId.eq(o.getID().getID()));
|
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
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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;
|
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.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingleQuery;
|
||||||
import com.mysema.query.sql.AbstractSQLQuery;
|
import com.mysema.query.sql.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
import com.mysema.query.sql.dml.SQLDeleteClause;
|
||||||
import com.mysema.query.sql.dml.SQLInsertClause;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CharacterFriendDAO} implementation for JDBC
|
* {@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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class SQLCharacterFriendDAO extends
|
public class SQLCharacterFriendDAO extends
|
||||||
AbstractSQLDAO<CharacterFriend, FriendID> implements
|
AbstractSQLDAO<CharacterFriend, FriendID> implements CharacterFriendDAO {
|
||||||
CharacterFriendDAO {
|
|
||||||
/**
|
/**
|
||||||
* The {@link CharacterFriend} mapper
|
* The {@link CharacterFriend} mapper
|
||||||
*/
|
*/
|
||||||
@@ -66,7 +64,7 @@ public class SQLCharacterFriendDAO extends
|
|||||||
@Override
|
@Override
|
||||||
public CharacterFriend select(final FriendID id) {
|
public CharacterFriend select(final FriendID id) {
|
||||||
return database
|
return database
|
||||||
.query(new SelectSingleQuery<CharacterFriend, QCharacterFriend>(
|
.query(new SelectSingleQuery<CharacterFriend, FriendID, FriendID, QCharacterFriend>(
|
||||||
QCharacterFriend.characterFriend, mapper) {
|
QCharacterFriend.characterFriend, mapper) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q,
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
@@ -81,7 +79,7 @@ public class SQLCharacterFriendDAO extends
|
|||||||
@Override
|
@Override
|
||||||
public void load(final L2Character character) {
|
public void load(final L2Character character) {
|
||||||
final List<CharacterFriend> list = database
|
final List<CharacterFriend> list = database
|
||||||
.query(new SelectListQuery<CharacterFriend, QCharacterFriend>(
|
.query(new SelectListQuery<CharacterFriend, FriendID, FriendID, QCharacterFriend>(
|
||||||
QCharacterFriend.characterFriend, mapper) {
|
QCharacterFriend.characterFriend, mapper) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q,
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
@@ -94,25 +92,22 @@ public class SQLCharacterFriendDAO extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FriendID> selectIDs() {
|
public List<FriendID> selectIDs() {
|
||||||
return database.query(new SelectListQuery<FriendID, QCharacterFriend>(
|
return database
|
||||||
QCharacterFriend.characterFriend, mapper.getIDMapper()) {
|
.query(new SelectListQuery<FriendID, FriendID, FriendID, QCharacterFriend>(
|
||||||
@Override
|
QCharacterFriend.characterFriend, mapper
|
||||||
protected void query(AbstractSQLQuery<?> q, QCharacterFriend e) {
|
.getIDMapper(QCharacterFriend.characterFriend)) {
|
||||||
}
|
@Override
|
||||||
});
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
|
QCharacterFriend e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertObjects(CharacterFriend... friends) {
|
public int insertObjects(CharacterFriend... friends) {
|
||||||
return database
|
return database
|
||||||
.query(new InsertQuery<CharacterFriend, QCharacterFriend, Object>(
|
.query(new InsertQuery<CharacterFriend, FriendID, FriendID, QCharacterFriend>(
|
||||||
QCharacterFriend.characterFriend, friends) {
|
QCharacterFriend.characterFriend, mapper, friends));
|
||||||
@Override
|
|
||||||
protected void map(SQLInsertClause q, CharacterFriend o) {
|
|
||||||
q.set(e.characterId, o.getCharacterID().getID()).set(
|
|
||||||
e.characterIdFriend, o.getFriendID().getID());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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;
|
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.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||||
import com.mysema.query.sql.AbstractSQLQuery;
|
import com.mysema.query.sql.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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.dml.SQLUpdateClause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +64,7 @@ public class SQLCharacterShortcutDAO extends
|
|||||||
@Override
|
@Override
|
||||||
public CharacterShortcut select(final CharacterShortcutID id) {
|
public CharacterShortcut select(final CharacterShortcutID id) {
|
||||||
return database
|
return database
|
||||||
.query(new SelectSingleQuery<CharacterShortcut, QCharacterShortcut>(
|
.query(new SelectSingleQuery<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||||
QCharacterShortcut.characterShortcut, mapper) {
|
QCharacterShortcut.characterShortcut, mapper) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q,
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
@@ -78,7 +77,7 @@ public class SQLCharacterShortcutDAO extends
|
|||||||
@Override
|
@Override
|
||||||
public List<CharacterShortcut> selectByCharacter(final L2Character character) {
|
public List<CharacterShortcut> selectByCharacter(final L2Character character) {
|
||||||
return database
|
return database
|
||||||
.query(new SelectListQuery<CharacterShortcut, QCharacterShortcut>(
|
.query(new SelectListQuery<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||||
QCharacterShortcut.characterShortcut, mapper) {
|
QCharacterShortcut.characterShortcut, mapper) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q,
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
@@ -91,9 +90,9 @@ public class SQLCharacterShortcutDAO extends
|
|||||||
@Override
|
@Override
|
||||||
public List<CharacterShortcutID> selectIDs() {
|
public List<CharacterShortcutID> selectIDs() {
|
||||||
return database
|
return database
|
||||||
.query(new SelectListQuery<CharacterShortcutID, QCharacterShortcut>(
|
.query(new SelectListQuery<CharacterShortcutID, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||||
QCharacterShortcut.characterShortcut, mapper
|
QCharacterShortcut.characterShortcut,
|
||||||
.getIDMapper()) {
|
mapper.getIDMapper(QCharacterShortcut.characterShortcut)) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q,
|
protected void query(AbstractSQLQuery<?> q,
|
||||||
QCharacterShortcut e) {
|
QCharacterShortcut e) {
|
||||||
@@ -104,44 +103,21 @@ public class SQLCharacterShortcutDAO extends
|
|||||||
@Override
|
@Override
|
||||||
public int insertObjects(CharacterShortcut... shortcuts) {
|
public int insertObjects(CharacterShortcut... shortcuts) {
|
||||||
return database
|
return database
|
||||||
.query(new InsertQuery<CharacterShortcut, QCharacterShortcut, Integer>(
|
.query(new InsertQuery<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut>(
|
||||||
QCharacterShortcut.characterShortcut,
|
QCharacterShortcut.characterShortcut, mapper,
|
||||||
QCharacterShortcut.characterShortcut.shortcutId,
|
QCharacterShortcut.characterShortcut.shortcutId,
|
||||||
shortcuts) {
|
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
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateObjects(CharacterShortcut... shortcuts) {
|
public int updateObjects(CharacterShortcut... shortcuts) {
|
||||||
return database
|
return database
|
||||||
.query(new UpdateQuery<CharacterShortcut, QCharacterShortcut>(
|
.query(new UpdateQuery<CharacterShortcut, QCharacterShortcut>(
|
||||||
QCharacterShortcut.characterShortcut, shortcuts) {
|
QCharacterShortcut.characterShortcut, mapper, shortcuts) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(SQLUpdateClause q, CharacterShortcut o) {
|
protected void query(SQLUpdateClause q, CharacterShortcut o) {
|
||||||
q.where(e.shortcutId.eq(o.getID().getID()));
|
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
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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.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.InsertQuery;
|
||||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectListQuery;
|
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectListQuery;
|
||||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingleQuery;
|
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.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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
|
* {@link CharacterDAO} implementation for JDBC
|
||||||
@@ -61,70 +58,38 @@ public class SQLChatMessageDAO extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatMessage select(final ChatMessageID id) {
|
public ChatMessage select(final ChatMessageID id) {
|
||||||
return database.query(new SelectSingleQuery<ChatMessage, QLogChat>(
|
return database
|
||||||
QLogChat.logChat, mapper) {
|
.query(new SelectSingleQuery<ChatMessage, Integer, ChatMessageID, QLogChat>(
|
||||||
@Override
|
QLogChat.logChat, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
@Override
|
||||||
q.where(e.messageId.eq(id.getID()));
|
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
||||||
}
|
q.where(e.messageId.eq(id.getID()));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ChatMessageID> selectIDs() {
|
public Collection<ChatMessageID> selectIDs() {
|
||||||
return database.query(new SelectListQuery<ChatMessageID, QLogChat>(
|
return database
|
||||||
QLogChat.logChat, mapper.getIDMapper()) {
|
.query(new SelectListQuery<ChatMessageID, Integer, ChatMessageID, QLogChat>(
|
||||||
@Override
|
QLogChat.logChat, mapper.getIDMapper(QLogChat.logChat)) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
@Override
|
||||||
}
|
protected void query(AbstractSQLQuery<?> q, QLogChat e) {
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertObjects(ChatMessage... objects) {
|
public int insertObjects(ChatMessage... objects) {
|
||||||
return database.query(new InsertQuery<ChatMessage, QLogChat, Integer>(
|
return database
|
||||||
QLogChat.logChat, QLogChat.logChat.messageId, objects) {
|
.query(new InsertQuery<ChatMessage, Integer, ChatMessageID, QLogChat>(
|
||||||
@Override
|
QLogChat.logChat, mapper, QLogChat.logChat.messageId,
|
||||||
protected void map(SQLInsertClause q, ChatMessage o) {
|
objects));
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateObjects(ChatMessage... objects) {
|
public int updateObjects(ChatMessage... objects) {
|
||||||
return database.query(new UpdateQuery<ChatMessage, QLogChat>(
|
return 0;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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.Collection;
|
||||||
|
|
||||||
@@ -35,7 +35,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.SelectSingl
|
|||||||
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
import com.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||||
import com.mysema.query.sql.AbstractSQLQuery;
|
import com.mysema.query.sql.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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.dml.SQLUpdateClause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,8 +42,7 @@ import com.mysema.query.sql.dml.SQLUpdateClause;
|
|||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class SQLClanDAO extends AbstractSQLDAO<Clan, ClanID> implements
|
public class SQLClanDAO extends AbstractSQLDAO<Clan, ClanID> implements ClanDAO {
|
||||||
ClanDAO {
|
|
||||||
private final ClanMapper mapper;
|
private final ClanMapper mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,52 +59,42 @@ public class SQLClanDAO extends AbstractSQLDAO<Clan, ClanID> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clan select(final ClanID id) {
|
public Clan select(final ClanID id) {
|
||||||
return database.query(new SelectSingleQuery<Clan, QClan>(QClan.clan,
|
return database
|
||||||
mapper) {
|
.query(new SelectSingleQuery<Clan, Integer, ClanID, QClan>(
|
||||||
@Override
|
QClan.clan, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
@Override
|
||||||
q.where(e.clanId.eq(id.getID()));
|
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
||||||
}
|
q.where(e.clanId.eq(id.getID()));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ClanID> selectIDs() {
|
public Collection<ClanID> selectIDs() {
|
||||||
return database.query(new SelectListQuery<ClanID, QClan>(QClan.clan,
|
return database
|
||||||
mapper.getIDMapper()) {
|
.query(new SelectListQuery<ClanID, Integer, ClanID, QClan>(
|
||||||
@Override
|
QClan.clan, mapper.getIDMapper(QClan.clan)) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
@Override
|
||||||
}
|
protected void query(AbstractSQLQuery<?> q, QClan e) {
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertObjects(Clan... objects) {
|
public int insertObjects(Clan... objects) {
|
||||||
return database.query(new InsertQuery<Clan, QClan, Integer>(QClan.clan,
|
return database.query(new InsertQuery<Clan, Integer, ClanID, QClan>(
|
||||||
QClan.clan.clanId, objects) {
|
QClan.clan, mapper, 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());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateObjects(Clan... objects) {
|
public int updateObjects(Clan... objects) {
|
||||||
return database
|
return database.query(new UpdateQuery<Clan, QClan>(QClan.clan, mapper,
|
||||||
.query(new UpdateQuery<Clan, QClan>(QClan.clan, objects) {
|
objects) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(SQLUpdateClause q, Clan o) {
|
protected void query(SQLUpdateClause q, Clan o) {
|
||||||
q.where(e.clanId.eq(o.getID().getID()));
|
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());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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.Collection;
|
||||||
import java.util.List;
|
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.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||||
import com.mysema.query.sql.AbstractSQLQuery;
|
import com.mysema.query.sql.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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.dml.SQLUpdateClause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,8 +44,7 @@ import com.mysema.query.sql.dml.SQLUpdateClause;
|
|||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class SQLItemDAO extends AbstractSQLDAO<Item, ItemID> implements
|
public class SQLItemDAO extends AbstractSQLDAO<Item, ItemID> implements ItemDAO {
|
||||||
ItemDAO {
|
|
||||||
private final ItemMapper mapper;
|
private final ItemMapper mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,103 +61,66 @@ public class SQLItemDAO extends AbstractSQLDAO<Item, ItemID> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item select(final ItemID id) {
|
public Item select(final ItemID id) {
|
||||||
return database.query(new SelectSingleQuery<Item, QItem>(QItem.item,
|
return database
|
||||||
mapper) {
|
.query(new SelectSingleQuery<Item, Integer, ItemID, QItem>(
|
||||||
@Override
|
QItem.item, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
@Override
|
||||||
q.where(e.itemId.eq(id.getID()));
|
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||||
}
|
q.where(e.itemId.eq(id.getID()));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Item> selectByCharacter(final L2Character character) {
|
public List<Item> selectByCharacter(final L2Character character) {
|
||||||
return database.query(new SelectListQuery<Item, QItem>(QItem.item,
|
return database
|
||||||
mapper) {
|
.query(new SelectListQuery<Item, Integer, ItemID, QItem>(
|
||||||
@Override
|
QItem.item, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
@Override
|
||||||
q.where(e.characterId.eq(character.getID().getID()));
|
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||||
}
|
q.where(e.characterId.eq(character.getID().getID()));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Item> selectDroppedItems() {
|
public List<Item> selectDroppedItems() {
|
||||||
return database.query(new SelectListQuery<Item, QItem>(QItem.item,
|
return database
|
||||||
mapper) {
|
.query(new SelectListQuery<Item, Integer, ItemID, QItem>(
|
||||||
@Override
|
QItem.item, mapper) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
@Override
|
||||||
q.where(e.location.eq(ItemLocation.GROUND));
|
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||||
}
|
q.where(e.location.eq(ItemLocation.GROUND));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ItemID> selectIDs() {
|
public Collection<ItemID> selectIDs() {
|
||||||
return database.query(new SelectListQuery<ItemID, QItem>(QItem.item,
|
return database
|
||||||
mapper.getIDMapper()) {
|
.query(new SelectListQuery<ItemID, Integer, ItemID, QItem>(
|
||||||
@Override
|
QItem.item, mapper.getIDMapper(QItem.item)) {
|
||||||
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
@Override
|
||||||
}
|
protected void query(AbstractSQLQuery<?> q, QItem e) {
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertObjects(Item... objects) {
|
public int insertObjects(Item... objects) {
|
||||||
return database.query(new InsertQuery<Item, QItem, Object>(QItem.item,
|
return database.query(new InsertQuery<Item, Integer, ItemID, QItem>(
|
||||||
objects) {
|
QItem.item, mapper, 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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateObjects(Item... objects) {
|
public int updateObjects(Item... objects) {
|
||||||
return database
|
return database.query(new UpdateQuery<Item, QItem>(QItem.item, mapper,
|
||||||
.query(new UpdateQuery<Item, QItem>(QItem.item, objects) {
|
objects) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(SQLUpdateClause q, Item o) {
|
protected void query(SQLUpdateClause q, Item o) {
|
||||||
q.where(e.itemId.eq(o.getID().getID()));
|
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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* 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.Collection;
|
||||||
import java.util.List;
|
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.l2jserver.service.database.sql.AbstractSQLDatabaseService.UpdateQuery;
|
||||||
import com.mysema.query.sql.AbstractSQLQuery;
|
import com.mysema.query.sql.AbstractSQLQuery;
|
||||||
import com.mysema.query.sql.dml.SQLDeleteClause;
|
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.dml.SQLUpdateClause;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,18 +61,19 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPC select(final NPCID id) {
|
public NPC select(final NPCID id) {
|
||||||
return database
|
return database.query(new SelectSingleQuery<NPC, Integer, NPCID, QNPC>(
|
||||||
.query(new SelectSingleQuery<NPC, QNPC>(QNPC.npc, mapper) {
|
QNPC.npc, mapper) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||||
q.where(e.npcId.eq(id.getID()));
|
q.where(e.npcId.eq(id.getID()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<NPC> loadAll() {
|
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
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,8 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NPC> selectByTemplate(final NPCTemplateID templateID) {
|
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
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||||
q.where(e.npcTemplateId.eq(templateID.getID()));
|
q.where(e.npcTemplateId.eq(templateID.getID()));
|
||||||
@@ -92,8 +93,8 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<NPCID> selectIDs() {
|
public Collection<NPCID> selectIDs() {
|
||||||
return database.query(new SelectListQuery<NPCID, QNPC>(QNPC.npc, mapper
|
return database.query(new SelectListQuery<NPCID, Integer, NPCID, QNPC>(
|
||||||
.getIDMapper()) {
|
QNPC.npc, mapper.getIDMapper(QNPC.npc)) {
|
||||||
@Override
|
@Override
|
||||||
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
protected void query(AbstractSQLQuery<?> q, QNPC e) {
|
||||||
}
|
}
|
||||||
@@ -102,63 +103,18 @@ public class SQLNPCDAO extends AbstractSQLDAO<NPC, NPCID> implements NPCDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertObjects(NPC... objects) {
|
public int insertObjects(NPC... objects) {
|
||||||
return database.query(new InsertQuery<NPC, QNPC, Object>(QNPC.npc,
|
return database.query(new InsertQuery<NPC, Integer, NPCID, QNPC>(
|
||||||
objects) {
|
QNPC.npc, mapper, 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());
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateObjects(NPC... objects) {
|
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
|
@Override
|
||||||
protected void query(SQLUpdateClause q, NPC o) {
|
protected void query(SQLUpdateClause q, NPC o) {
|
||||||
q.where(e.npcId.eq(o.getID().getID()));
|
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.CharacterID;
|
||||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||||
import com.l2jserver.model.id.provider.FriendIDProvider;
|
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.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;
|
import com.l2jserver.service.database.model.QCharacterFriend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CharacterFriendMapper implements
|
public class CharacterFriendMapper extends
|
||||||
Mapper<CharacterFriend, QCharacterFriend> {
|
AbstractMapper<CharacterFriend, FriendID, FriendID, QCharacterFriend> {
|
||||||
private final Mapper<FriendID, QCharacterFriend> idMapper = new Mapper<FriendID, QCharacterFriend>() {
|
// private final CompoundPrimaryKeyMapper<FriendID, CharacterID,
|
||||||
@Override
|
// CharacterID, QCharacterFriend> idMapper = new
|
||||||
public FriendID map(QCharacterFriend e, DatabaseRow row) {
|
// CompoundPrimaryKeyMapper<FriendID, CharacterID, CharacterID,
|
||||||
return idProvider.createID(
|
// QCharacterFriend>() {
|
||||||
charIdProvider.resolveID(row.get(e.characterId)),
|
// @Override
|
||||||
charIdProvider.resolveID(row.get(e.characterIdFriend)));
|
// 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
|
* The {@link CharacterID} provider
|
||||||
@@ -64,13 +81,26 @@ public class CharacterFriendMapper implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharacterFriend map(QCharacterFriend e, DatabaseRow row) {
|
public CharacterFriend select(QCharacterFriend e, DatabaseRow row) {
|
||||||
return new CharacterFriend(idProvider.createID(
|
return new CharacterFriend(idProvider.createID(
|
||||||
charIdProvider.resolveID(row.get(e.characterId)),
|
charIdProvider.resolveID(row.get(e.characterId)),
|
||||||
charIdProvider.resolveID(row.get(e.characterIdFriend))));
|
charIdProvider.resolveID(row.get(e.characterIdFriend))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mapper<FriendID, QCharacterFriend> getIDMapper() {
|
@Override
|
||||||
return idMapper;
|
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.CharacterClass;
|
||||||
import com.l2jserver.model.template.character.CharacterTemplate;
|
import com.l2jserver.model.template.character.CharacterTemplate;
|
||||||
import com.l2jserver.model.world.L2Character;
|
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.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.service.database.model.QCharacter;
|
||||||
import com.l2jserver.util.geometry.Point3D;
|
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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CharacterMapper implements Mapper<L2Character, QCharacter> {
|
public class CharacterMapper extends
|
||||||
private final Mapper<CharacterID, QCharacter> idMapper = new Mapper<CharacterID, QCharacter>() {
|
AbstractMapper<L2Character, Integer, CharacterID, QCharacter> {
|
||||||
|
private final PrimaryKeyMapper<CharacterID, Integer> pk = new PrimaryKeyMapper<CharacterID, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public CharacterID map(QCharacter e, DatabaseRow row) {
|
public CharacterID createID(Integer raw) {
|
||||||
return idProvider.resolveID(row.get(e.characterId));
|
return idProvider.resolveID(raw);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,7 +87,7 @@ public class CharacterMapper implements Mapper<L2Character, QCharacter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public L2Character map(QCharacter e, DatabaseRow row) {
|
public L2Character select(QCharacter e, DatabaseRow row) {
|
||||||
final CharacterClass charClass = row.get(e.characterClass);
|
final CharacterClass charClass = row.get(e.characterClass);
|
||||||
final CharacterTemplateID templateId = templateIdProvider
|
final CharacterTemplateID templateId = templateIdProvider
|
||||||
.resolveID(charClass.id);
|
.resolveID(charClass.id);
|
||||||
@@ -122,8 +125,43 @@ public class CharacterMapper implements Mapper<L2Character, QCharacter> {
|
|||||||
|
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mapper<CharacterID, QCharacter> getIDMapper() {
|
@Override
|
||||||
return idMapper;
|
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.CharacterIDProvider;
|
||||||
import com.l2jserver.model.id.object.provider.ItemIDProvider;
|
import com.l2jserver.model.id.object.provider.ItemIDProvider;
|
||||||
import com.l2jserver.model.id.provider.CharacterShortcutIDProvider;
|
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.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;
|
import com.l2jserver.service.database.model.QCharacterShortcut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CharacterShortcutMapper implements
|
public class CharacterShortcutMapper
|
||||||
Mapper<CharacterShortcut, QCharacterShortcut> {
|
extends
|
||||||
private final Mapper<CharacterShortcutID, QCharacterShortcut> idMapper = new Mapper<CharacterShortcutID, QCharacterShortcut>() {
|
AbstractMapper<CharacterShortcut, Integer, CharacterShortcutID, QCharacterShortcut> {
|
||||||
|
private final PrimaryKeyMapper<CharacterShortcutID, Integer> idMapper = new PrimaryKeyMapper<CharacterShortcutID, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public CharacterShortcutID map(QCharacterShortcut e, DatabaseRow row) {
|
public CharacterShortcutID createID(Integer raw) {
|
||||||
return idProvider.resolveID(row.get(e.shortcutId));
|
return idProvider.resolveID(raw);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,7 +78,7 @@ public class CharacterShortcutMapper implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharacterShortcut map(QCharacterShortcut e, DatabaseRow row) {
|
public CharacterShortcut select(QCharacterShortcut e, DatabaseRow row) {
|
||||||
final CharacterShortcut shortcut = new CharacterShortcut();
|
final CharacterShortcut shortcut = new CharacterShortcut();
|
||||||
shortcut.setID(idProvider.resolveID(row.get(e.shortcutId)));
|
shortcut.setID(idProvider.resolveID(row.get(e.shortcutId)));
|
||||||
final CharacterID charId = charIdProvider.resolveID(row
|
final CharacterID charId = charIdProvider.resolveID(row
|
||||||
@@ -98,7 +101,23 @@ public class CharacterShortcutMapper implements
|
|||||||
return shortcut;
|
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;
|
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.object.provider.CharacterIDProvider;
|
||||||
import com.l2jserver.model.id.provider.ChatMessageIDProvider;
|
import com.l2jserver.model.id.provider.ChatMessageIDProvider;
|
||||||
import com.l2jserver.model.server.ChatMessage;
|
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.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;
|
import com.l2jserver.service.database.model.QLogChat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ChatMessageMapper implements Mapper<ChatMessage, QLogChat> {
|
public class ChatMessageMapper extends
|
||||||
private final Mapper<ChatMessageID, QLogChat> idMapper = new Mapper<ChatMessageID, QLogChat>() {
|
AbstractMapper<ChatMessage, Integer, ChatMessageID, QLogChat> {
|
||||||
|
private final PrimaryKeyMapper<ChatMessageID, Integer> idMapper = new PrimaryKeyMapper<ChatMessageID, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public ChatMessageID map(QLogChat e, DatabaseRow row) {
|
public ChatMessageID createID(Integer raw) {
|
||||||
return idProvider.resolveID(row.get(e.messageId));
|
return idMapper.createID(raw);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,7 +66,7 @@ public class ChatMessageMapper implements Mapper<ChatMessage, QLogChat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatMessage map(QLogChat e, DatabaseRow row) {
|
public ChatMessage select(QLogChat e, DatabaseRow row) {
|
||||||
final ChatMessage message = new ChatMessage();
|
final ChatMessage message = new ChatMessage();
|
||||||
message.setID(idProvider.resolveID(row.get(e.messageId)));
|
message.setID(idProvider.resolveID(row.get(e.messageId)));
|
||||||
|
|
||||||
@@ -83,7 +86,28 @@ public class ChatMessageMapper implements Mapper<ChatMessage, QLogChat> {
|
|||||||
return message;
|
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;
|
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.CharacterIDProvider;
|
||||||
import com.l2jserver.model.id.object.provider.ClanIDProvider;
|
import com.l2jserver.model.id.object.provider.ClanIDProvider;
|
||||||
import com.l2jserver.model.world.Clan;
|
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.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;
|
import com.l2jserver.service.database.model.QClan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ClanMapper implements Mapper<Clan, QClan> {
|
public class ClanMapper extends AbstractMapper<Clan, Integer, ClanID, QClan> {
|
||||||
private final Mapper<ClanID, QClan> idMapper = new Mapper<ClanID, QClan>() {
|
private final PrimaryKeyMapper<ClanID, Integer> idMapper = new PrimaryKeyMapper<ClanID, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public ClanID map(QClan e, DatabaseRow row) {
|
public ClanID createID(Integer raw) {
|
||||||
return idProvider.resolveID(row.get(e.clanId));
|
return idProvider.resolveID(raw);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,14 +64,26 @@ public class ClanMapper implements Mapper<Clan, QClan> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clan map(QClan e, DatabaseRow row) {
|
public Clan select(QClan e, DatabaseRow row) {
|
||||||
final Clan clan = new Clan();
|
final Clan clan = new Clan();
|
||||||
clan.setID(idProvider.resolveID(row.get(e.clanId)));
|
clan.setID(idProvider.resolveID(row.get(e.clanId)));
|
||||||
clan.setID(charIdProvider.resolveID(row.get(e.characterIdLeader)));
|
clan.setID(charIdProvider.resolveID(row.get(e.characterIdLeader)));
|
||||||
return clan;
|
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;
|
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.id.template.provider.ItemTemplateIDProvider;
|
||||||
import com.l2jserver.model.template.item.ItemTemplate;
|
import com.l2jserver.model.template.item.ItemTemplate;
|
||||||
import com.l2jserver.model.world.Item;
|
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.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.service.database.model.QItem;
|
||||||
import com.l2jserver.util.geometry.Coordinate;
|
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>
|
* @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
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
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
|
@Override
|
||||||
public ItemID map(QItem e, DatabaseRow row) {
|
public ItemID createID(Integer raw) {
|
||||||
return idProvider.resolveID(row.get(e.itemId));
|
return idProvider.resolveID(raw);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ public class ItemMapper implements Mapper<Item, QItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 ItemID id = idProvider.resolveID(row.get(e.itemId));
|
||||||
final ItemTemplateID templateId = templateIdProvider.resolveID(row
|
final ItemTemplateID templateId = templateIdProvider.resolveID(row
|
||||||
.get(e.templateId));
|
.get(e.templateId));
|
||||||
@@ -113,7 +115,34 @@ public class ItemMapper implements Mapper<Item, QItem> {
|
|||||||
return item;
|
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;
|
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.id.template.provider.NPCTemplateIDProvider;
|
||||||
import com.l2jserver.model.template.npc.NPCTemplate;
|
import com.l2jserver.model.template.npc.NPCTemplate;
|
||||||
import com.l2jserver.model.world.NPC;
|
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.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.service.database.model.QNPC;
|
||||||
import com.l2jserver.util.geometry.Point3D;
|
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>
|
* @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
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
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
|
@Override
|
||||||
public NPCID map(QNPC e, DatabaseRow row) {
|
public NPCID createID(Integer raw) {
|
||||||
return idProvider.resolveID(row.get(e.npcId));
|
return idProvider.resolveID(raw);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ public class NPCMapper implements Mapper<NPC, QNPC> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPC map(QNPC e, DatabaseRow row) {
|
public NPC select(QNPC e, DatabaseRow row) {
|
||||||
final NPCID id = idProvider.resolveID(row.get(e.npcId));
|
final NPCID id = idProvider.resolveID(row.get(e.npcId));
|
||||||
NPCTemplateID templateId = templateIdProvider.resolveID(row
|
NPCTemplateID templateId = templateIdProvider.resolveID(row
|
||||||
.get(e.npcTemplateId));
|
.get(e.npcTemplateId));
|
||||||
@@ -99,7 +101,35 @@ public class NPCMapper implements Mapper<NPC, QNPC> {
|
|||||||
return npc;
|
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;
|
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.CharacterClass;
|
||||||
import com.l2jserver.model.template.character.CharacterRace;
|
import com.l2jserver.model.template.character.CharacterRace;
|
||||||
import com.l2jserver.model.world.Clan;
|
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.CharacterFace;
|
||||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairColor;
|
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairColor;
|
||||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairStyle;
|
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>
|
* @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;
|
private static final long serialVersionUID = -59499032;
|
||||||
|
|
||||||
public static final QCharacter character = new QCharacter("l2character");
|
public static final QCharacter character = new QCharacter("l2character");
|
||||||
@@ -82,19 +81,19 @@ public class QCharacter extends RelationalPathBase<L2Character> {
|
|||||||
public final EnumPath<CharacterFace> apperanceFace = createEnum(
|
public final EnumPath<CharacterFace> apperanceFace = createEnum(
|
||||||
"apperance_face", CharacterFace.class);
|
"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 final ForeignKey<Clan> clanIdKey = createForeignKey(clanId, "");
|
||||||
|
|
||||||
public QCharacter(String variable) {
|
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");
|
super(entity.getType(), entity.getMetadata(), "null", "character");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QCharacter(PathMetadata<?> metadata) {
|
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 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.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||||
import com.mysema.query.sql.PrimaryKey;
|
import com.mysema.query.sql.PrimaryKey;
|
||||||
import com.mysema.query.types.Path;
|
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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class QCharacterFriend extends
|
public class QCharacterFriend extends
|
||||||
com.mysema.query.sql.RelationalPathBase<CharacterFriend> {
|
com.mysema.query.sql.RelationalPathBase<FriendID> {
|
||||||
private static final long serialVersionUID = 1488651942;
|
private static final long serialVersionUID = 1488651942;
|
||||||
|
|
||||||
public static final QCharacterFriend characterFriend = new QCharacterFriend(
|
public static final QCharacterFriend characterFriend = new QCharacterFriend(
|
||||||
@@ -28,21 +28,20 @@ public class QCharacterFriend extends
|
|||||||
public final NumberPath<Integer> characterIdFriend = createNumber(
|
public final NumberPath<Integer> characterIdFriend = createNumber(
|
||||||
"character_id_friend", Integer.class);
|
"character_id_friend", Integer.class);
|
||||||
|
|
||||||
public final PrimaryKey<CharacterFriend> primary = createPrimaryKey(
|
public final PrimaryKey<FriendID> primary = createPrimaryKey(characterId,
|
||||||
characterId, characterIdFriend);
|
characterIdFriend);
|
||||||
|
|
||||||
public QCharacterFriend(String variable) {
|
public QCharacterFriend(String variable) {
|
||||||
super(CharacterFriend.class, forVariable(variable), "null",
|
super(FriendID.class, forVariable(variable), "null", "character_friend");
|
||||||
"character_friend");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public QCharacterFriend(Path<? extends CharacterFriend> entity) {
|
public QCharacterFriend(Path<? extends FriendID> entity) {
|
||||||
super(entity.getType(), entity.getMetadata(), "null",
|
super(entity.getType(), entity.getMetadata(), "null",
|
||||||
"character_friend");
|
"character_friend");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QCharacterFriend(PathMetadata<?> metadata) {
|
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 static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||||
|
|
||||||
import com.l2jserver.model.game.CharacterShortcut;
|
|
||||||
import com.l2jserver.model.game.CharacterShortcut.ShortcutType;
|
import com.l2jserver.model.game.CharacterShortcut.ShortcutType;
|
||||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnAutoIncrement;
|
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.ColumnNullable;
|
||||||
@@ -19,7 +18,7 @@ import com.mysema.query.types.path.NumberPath;
|
|||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class QCharacterShortcut extends
|
public class QCharacterShortcut extends
|
||||||
com.mysema.query.sql.RelationalPathBase<CharacterShortcut> {
|
com.mysema.query.sql.RelationalPathBase<Integer> {
|
||||||
private static final long serialVersionUID = 1450964558;
|
private static final long serialVersionUID = 1450964558;
|
||||||
|
|
||||||
public static final QCharacterShortcut characterShortcut = new QCharacterShortcut(
|
public static final QCharacterShortcut characterShortcut = new QCharacterShortcut(
|
||||||
@@ -52,20 +51,20 @@ public class QCharacterShortcut extends
|
|||||||
public final EnumPath<ShortcutType> type = createEnum("type",
|
public final EnumPath<ShortcutType> type = createEnum("type",
|
||||||
ShortcutType.class);
|
ShortcutType.class);
|
||||||
|
|
||||||
public final PrimaryKey<CharacterShortcut> primary = createPrimaryKey(shortcutId);
|
public final PrimaryKey<Integer> primary = createPrimaryKey(shortcutId);
|
||||||
|
|
||||||
public QCharacterShortcut(String variable) {
|
public QCharacterShortcut(String variable) {
|
||||||
super(CharacterShortcut.class, forVariable(variable), "null",
|
super(Integer.class, forVariable(variable), "null",
|
||||||
"character_shortcut");
|
"character_shortcut");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QCharacterShortcut(Path<? extends CharacterShortcut> entity) {
|
public QCharacterShortcut(Path<? extends Integer> entity) {
|
||||||
super(entity.getType(), entity.getMetadata(), "null",
|
super(entity.getType(), entity.getMetadata(), "null",
|
||||||
"character_shortcut");
|
"character_shortcut");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QCharacterShortcut(PathMetadata<?> metadata) {
|
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 static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||||
|
|
||||||
import com.l2jserver.model.world.Clan;
|
|
||||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||||
import com.mysema.query.sql.PrimaryKey;
|
import com.mysema.query.sql.PrimaryKey;
|
||||||
import com.mysema.query.types.Path;
|
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>
|
* @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;
|
private static final long serialVersionUID = 1592083511;
|
||||||
|
|
||||||
public static final QClan clan = new QClan("clan");
|
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(
|
public final NumberPath<Integer> characterIdLeader = createNumber(
|
||||||
"character_id_leader", Integer.class);
|
"character_id_leader", Integer.class);
|
||||||
|
|
||||||
public final PrimaryKey<Clan> primary = createPrimaryKey(clanId);
|
public final PrimaryKey<Integer> primary = createPrimaryKey(clanId);
|
||||||
|
|
||||||
public QClan(String variable) {
|
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");
|
super(entity.getType(), entity.getMetadata(), "null", "clan");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QClan(PathMetadata<?> metadata) {
|
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 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.InventoryPaperdoll;
|
||||||
import com.l2jserver.model.world.character.CharacterInventory.ItemLocation;
|
import com.l2jserver.model.world.character.CharacterInventory.ItemLocation;
|
||||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnDefault;
|
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>
|
* @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;
|
private static final long serialVersionUID = 1592270068;
|
||||||
|
|
||||||
public static final QItem item = new QItem("item");
|
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(
|
public final EnumPath<InventoryPaperdoll> paperdoll = createEnum(
|
||||||
"paperdoll", InventoryPaperdoll.class);
|
"paperdoll", InventoryPaperdoll.class);
|
||||||
|
|
||||||
public final PrimaryKey<Item> primary = createPrimaryKey(itemId);
|
public final PrimaryKey<Integer> primary = createPrimaryKey(itemId);
|
||||||
|
|
||||||
public QItem(String variable) {
|
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");
|
super(entity.getType(), entity.getMetadata(), "null", "item");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QItem(PathMetadata<?> metadata) {
|
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 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.ColumnAutoIncrement;
|
||||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnNullable;
|
import com.l2jserver.service.database.sql.ddl.annotation.ColumnNullable;
|
||||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
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>
|
* @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;
|
private static final long serialVersionUID = -76124357;
|
||||||
|
|
||||||
public static final QLogChat logChat = new QLogChat("log_chat");
|
public static final QLogChat logChat = new QLogChat("log_chat");
|
||||||
@@ -31,7 +30,7 @@ public class QLogChat extends com.mysema.query.sql.RelationalPathBase<ChatMessag
|
|||||||
@ColumnAutoIncrement
|
@ColumnAutoIncrement
|
||||||
public final NumberPath<Integer> messageId = createNumber("message_id",
|
public final NumberPath<Integer> messageId = createNumber("message_id",
|
||||||
Integer.class);
|
Integer.class);
|
||||||
|
|
||||||
@ColumnSize(10)
|
@ColumnSize(10)
|
||||||
@ColumnNullable
|
@ColumnNullable
|
||||||
public final NumberPath<Integer> channelId = createNumber("channel_id",
|
public final NumberPath<Integer> channelId = createNumber("channel_id",
|
||||||
@@ -49,18 +48,18 @@ public class QLogChat extends com.mysema.query.sql.RelationalPathBase<ChatMessag
|
|||||||
public final EnumPath<ChatMessageType> type = createEnum("type",
|
public final EnumPath<ChatMessageType> type = createEnum("type",
|
||||||
ChatMessageType.class);
|
ChatMessageType.class);
|
||||||
|
|
||||||
public final PrimaryKey<ChatMessage> primary = createPrimaryKey(messageId);
|
public final PrimaryKey<Integer> primary = createPrimaryKey(messageId);
|
||||||
|
|
||||||
public QLogChat(String variable) {
|
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");
|
super(entity.getType(), entity.getMetadata(), "null", "log_chat");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QLogChat(PathMetadata<?> metadata) {
|
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 static com.mysema.query.types.PathMetadataFactory.forVariable;
|
||||||
|
|
||||||
import com.l2jserver.model.world.NPC;
|
|
||||||
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
|
||||||
import com.mysema.query.sql.PrimaryKey;
|
import com.mysema.query.sql.PrimaryKey;
|
||||||
import com.mysema.query.types.Path;
|
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>
|
* @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;
|
private static final long serialVersionUID = 2129578208;
|
||||||
|
|
||||||
public static final QNPC npc = new QNPC("npc");
|
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> hp = createNumber("hp", Double.class);
|
||||||
public final NumberPath<Double> mp = createNumber("mp", Double.class);
|
public final NumberPath<Double> mp = createNumber("mp", Double.class);
|
||||||
|
|
||||||
public final NumberPath<Double> pointAngle = createNumber("point_angle",
|
|
||||||
Double.class);
|
|
||||||
@ColumnSize(10)
|
@ColumnSize(10)
|
||||||
public final NumberPath<Integer> pointX = createNumber("point_x",
|
public final NumberPath<Integer> pointX = createNumber("point_x",
|
||||||
Integer.class);
|
Integer.class);
|
||||||
@@ -40,23 +37,25 @@ public class QNPC extends com.mysema.query.sql.RelationalPathBase<NPC> {
|
|||||||
@ColumnSize(10)
|
@ColumnSize(10)
|
||||||
public final NumberPath<Integer> pointZ = createNumber("point_z",
|
public final NumberPath<Integer> pointZ = createNumber("point_z",
|
||||||
Integer.class);
|
Integer.class);
|
||||||
|
public final NumberPath<Double> pointAngle = createNumber("point_angle",
|
||||||
|
Double.class);
|
||||||
|
|
||||||
@ColumnSize(8)
|
@ColumnSize(8)
|
||||||
public final NumberPath<Long> respawnTime = createNumber("respawn_time",
|
public final NumberPath<Long> respawnTime = createNumber("respawn_time",
|
||||||
Long.class);
|
Long.class);
|
||||||
|
|
||||||
public final PrimaryKey<NPC> primary = createPrimaryKey(npcId);
|
public final PrimaryKey<Integer> primary = createPrimaryKey(npcId);
|
||||||
|
|
||||||
public QNPC(String variable) {
|
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");
|
super(entity.getType(), entity.getMetadata(), "null", "npc");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QNPC(PathMetadata<?> metadata) {
|
public QNPC(PathMetadata<?> metadata) {
|
||||||
super(NPC.class, metadata, "null", "npc");
|
super(Integer.class, metadata, "null", "npc");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user