Obiekt sesji tworzę w sposób następujący:
private static Session session;
static {
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings (configuration.getProperties()).buildServiceRegistry();
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
session = sessionFactory.openSession();
}
public Session currentSession() {
return session;
}
Metoda usuwająca obiekt, to po prostu:
currentSession().delete(category);
gdzie category to po prostu obiekt klasy Category, który jest odpowiednio zmapowany.
Gdy wywołam powyższą metodę usuwającą, to otrzymuję na konsoli:
2012-03-23 1809 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2012-03-23 1809 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.0.Final}
2012-03-23 1809 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2012-03-23 1809 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2012-03-23 1809 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2012-03-23 1809 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2012-03-23 1809 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
2012-03-23 1809 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
2012-03-23 1809 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 10
2012-03-23 1809 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
2012-03-23 1809 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc//localhost/data]
2012-03-23 1809 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****}
2012-03-23 1809 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2012-03-23 1809 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2012-03-23 1809 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
2012-03-23 1809 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select category0_.id as id0_1_, category0_.name as name0_1_, category0_.parentId as parentId0_1_, category0_.status as status0_1_, category1_.id as id0_0_, category1_.name as name0_0_, category1_.parentId as parentId0_0_, category1_.status as status0_0_ from categories category0_ left outer join categories category1_ on category0_.parentId=category1_.id where category0_.id=?
i obiekt nie jest usunięty z bazy danych ... dlaczego?