// Path: DB/src/main/java/com/zhaoxiaodan/mirserver/db/DB.java
// public class DB {
// 
// 	private static SessionFactory  ourSessionFactory;
// 	private static ServiceRegistry serviceRegistry;
// 
// 	public static void init() throws Exception {
// 		Configuration configuration = new Configuration();
// 		configuration.configure();
// 
// 		serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
// 		ourSessionFactory = configuration.buildSessionFactory();
// 	}
// 
// 	public static Session getSession() {
// 		return ourSessionFactory.getCurrentSession();
// 	}
// 
// 	public static void save(Object object) {
// 		getSession().save(object);
// 	}
// 
// 	public static void update(Object object) {
// 		getSession().update(object);
// 	}
// 
// 	public static void delete(Object object) {
// 		getSession().delete(object);
// 	}
// 
// 	public static List query(Class clazz, SimpleExpression... simpleExpressions) {
// 		Criteria criteria = getSession().createCriteria(clazz);
// 		for (SimpleExpression simpleExpression : simpleExpressions) {
// 			criteria.add(simpleExpression);
// 		}
// 		List result = criteria.list();
// 		return result;
// 	}
// 
// }
// 
// Path: Core/src/main/java/com/zhaoxiaodan/mirserver/network/packets/ClientPacket.java
// public class ClientPacket extends Packet {
// 
// 	public byte cmdIndex;  // #号后面紧跟的序号, 响应包的序号要跟请求一直
// 
// 	public ClientPacket() {}
// 
// 	public ClientPacket(Protocol pid, byte cmdIndex) {
// 		super(0, pid, (short) 0, (short) 0, (short) 0);
// 		this.cmdIndex = cmdIndex;
// 	}
// 
// 	@Override
// 	public void readPacket(ByteBuf in) throws Parcelable.WrongFormatException {
// 		cmdIndex = in.readByte();
// 		cmdIndex = (byte) (cmdIndex - '0');
// 		super.readPacket(in);
// 	}
// 
// 	@Override
// 	public void writePacket(ByteBuf out) {
// 		out.writeByte(cmdIndex + '0');
// 		super.writePacket(out);
// 	}
// }


import com.zhaoxiaodan.mirserver.db.DB;
import com.zhaoxiaodan.mirserver.network.packets.ClientPacket;
import io.netty.channel.ChannelHandlerContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.resource.transaction.spi.TransactionStatus;
package com.zhaoxiaodan.mirserver.network;


public abstract class Handler {
	protected Logger logger = LogManager.getLogger(this.getClass().getName());
	protected Session session;

	protected void exce(ChannelHandlerContext ctx, ClientPacket packet) throws Exception {
		session = Session.getSession(ctx);
		if(null == session){
			logger.debug("new session for {}",ctx);
			session = Session.create(ctx);
		}
// Path: DB/src/main/java/com/zhaoxiaodan/mirserver/db/DB.java
// public class DB {
// 
// 	private static SessionFactory  ourSessionFactory;
// 	private static ServiceRegistry serviceRegistry;
// 
// 	public static void init() throws Exception {
// 		Configuration configuration = new Configuration();
// 		configuration.configure();
// 
// 		serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
// 		ourSessionFactory = configuration.buildSessionFactory();
// 	}
// 
// 	public static Session getSession() {
// 		return ourSessionFactory.getCurrentSession();
// 	}
// 
// 	public static void save(Object object) {
// 		getSession().save(object);
// 	}
// 
// 	public static void update(Object object) {
// 		getSession().update(object);
// 	}
// 
// 	public static void delete(Object object) {
// 		getSession().delete(object);
// 	}
// 
// 	public static List query(Class clazz, SimpleExpression... simpleExpressions) {
// 		Criteria criteria = getSession().createCriteria(clazz);
// 		for (SimpleExpression simpleExpression : simpleExpressions) {
// 			criteria.add(simpleExpression);
// 		}
// 		List result = criteria.list();
// 		return result;
// 	}
// 
// }
// 
// Path: Core/src/main/java/com/zhaoxiaodan/mirserver/network/packets/ClientPacket.java
// public class ClientPacket extends Packet {
// 
// 	public byte cmdIndex;  // #号后面紧跟的序号, 响应包的序号要跟请求一直
// 
// 	public ClientPacket() {}
// 
// 	public ClientPacket(Protocol pid, byte cmdIndex) {
// 		super(0, pid, (short) 0, (short) 0, (short) 0);
// 		this.cmdIndex = cmdIndex;
// 	}
// 
// 	@Override
// 	public void readPacket(ByteBuf in) throws Parcelable.WrongFormatException {
// 		cmdIndex = in.readByte();
// 		cmdIndex = (byte) (cmdIndex - '0');
// 		super.readPacket(in);
// 	}
// 
// 	@Override
// 	public void writePacket(ByteBuf out) {
// 		out.writeByte(cmdIndex + '0');
// 		super.writePacket(out);
// 	}
// }


// Path: Core/src/main/java/com/zhaoxiaodan/mirserver/network/Handler.java
import com.zhaoxiaodan.mirserver.db.DB;
import com.zhaoxiaodan.mirserver.network.packets.ClientPacket;
import io.netty.channel.ChannelHandlerContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.resource.transaction.spi.TransactionStatus;

package com.zhaoxiaodan.mirserver.network;


public abstract class Handler {
	protected Logger logger = LogManager.getLogger(this.getClass().getName());
	protected Session session;

	protected void exce(ChannelHandlerContext ctx, ClientPacket packet) throws Exception {
		session = Session.getSession(ctx);
		if(null == session){
			logger.debug("new session for {}",ctx);
			session = Session.create(ctx);
		}
		DB.getSession().getTransaction().begin();