sessionfactory

java.lang.IllegalArgumentException: expecting IdClass mapping

孤人 提交于 2019-12-22 01:32:56
问题 I have configured composite primary key for my entity Employee as follows Employee.java: @Entity @Table(name="employee") @Proxy(lazy=false) @IdClass(EmployeeId.class) public class Employee implements Serializable { private static final long serialVersionUID = 1L; private EmployeeId employeeId; private Person person; private Branch branch; private boolean isActive; public Employee() { } @EmbeddedId @AttributeOverrides({ @AttributeOverride(name="person", column = @Column(name="person_id")),

NHibernate & WCF: Performance (session reuse) vs. concurrency (simultaneous requests)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 04:58:01
问题 We are working on different integrations to a swarm of identically structured legacy databases that basically cannot be altered. For this, we added an auxiliary database for holding things like meta-information, routing rules and for temporarily holding data for the legacy databases. We are mainly using NHibernate to connect to the databases. One application is a WCF Service that needs to inserts incoming data into nested tables that are really wide (dozens of columns). Obviously, performance

Spring Hibernate SessionFactory

无人久伴 提交于 2019-12-19 03:44:16
问题 How do you create a SessionFactory using the java config? @Bean public SessionFactory sessionFactory(){ AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean(); sessionFactoryBean.setConfigLocation(new ClassPathResource("hibernate.cfg.xml")); return sessionFactoryBean.getObject(); } This doesnt work for some reason...it always returns null. 回答1: Worth noting here that Spring 3.1 introduces LocalSessionFactoryBuilder, which is expressly designed for use within

Nhibernate session management strategy for web application with background-workers?

被刻印的时光 ゝ 提交于 2019-12-19 03:38:09
问题 For a web application, it seems like a good way to handle the session is to use the setting <property name="current_session_context_class">managed_web</property> , call CurrentSessionContext.Bind/Unbind on Begin/EndRequest. Then I can just use sessionFactory.GetCurrentSession() in the repository class. This works fine for all page request. But I have background workers doing stuff and using the same repository classes to do stuff. These do not run within a web request, so that session

Configure sessionFactory with Spring, Hibernate and LocalSessionFactoryBuilder

﹥>﹥吖頭↗ 提交于 2019-12-18 16:53:34
问题 I'm trying to create sessionFactory bean using spring 3.2 and hibernate 4. I used the following code for that. But the problem is buildSessionFactory() is deprecated and the buildSessionFactory(ServiceRegistry serviceRegistry) is suggested to use instead in javadoc. However, I'm not being able to understand what is ServiceRegistry and how to use buildSessionFactory(ServiceRegistry serviceRegistry) . @Configuration public class AppConfig { ... @Bean public SessionFactory sessionFactory() {

No CurrentSessionContext configured

独自空忆成欢 提交于 2019-12-18 05:55:40
问题 sorry for bad English. I get my project started with spring-boot 1.1.8 , Encountered Exception No CurrentSessionContext configured , then I did some search, add property <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property> could solve this problem, but how to config this property using java class? update: I changed to the Hibernate4.x Way to define SessionFactory but still got the same error, please help! Use java 1.8 and speing

Hibernate SessionFactory vs. EntityManagerFactory

血红的双手。 提交于 2019-12-17 06:19:10
问题 I am new to Hibernate and am unclear of whether to use a SessionFactory or EntityManagerFactory to obtain the hibernate session. What is the difference between the two? Pros & Cons? 回答1: Prefer EntityManagerFactory and EntityManager . They are defined by the JPA standard. SessionFactory and Session are hibernate-specific. The EntityManager invokes the hibernate session under the hood. And if you need some specific features that are not available in the EntityManager , you can obtain the

ORA-12519, TNS:no appropriate service handler found

≡放荡痞女 提交于 2019-12-13 13:24:13
问题 I am closing the hibernate connection properly but i am getting this error after some clicks or after some page refreshes. whats the problem i cant understand. I have also checked the number of sessions its also increasing by the following command and program code is also given: Managedbean code: public List<TrxFile> getFileDetails() { //SessionFactory sf = HibernateUtill.HibernateUtil.getSessionFactory(); Session sess = HibernateUtill.HibernateUtil.getSessionFactory().openSession(); java

What pooled data source should I use for Spring 3.1.0, Hibernate 4.0.1.Final, and MySQL 5.1?

自古美人都是妖i 提交于 2019-12-13 12:06:42
问题 I'm using Spring 3.1.0.RELEASE, Hibernate 4.0.1.Final, and MySQL 5.1. What is the pooled data source I should be using? I'm currently using (snippet from application context file) ... <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/myproj</value> </property> <property name="username"> <value>myproj</value> <

Fluent NHibernate? Am I doing this correctly?

一笑奈何 提交于 2019-12-12 06:15:20
问题 I am new to using Fluent NHibernate and NHibernate for the first time. I've used a custom written mapper since about 2000 that was written in house. Made a switch to LinqToSQL about 2 years ago, and about 6 months ago to Entities. I'd like to see what Fluent/NHibernate have to offer. However, I can't seem to get it to run correctly. The following is a copy of my classes, their references, the ClassMaps. Can someone tell me if this simple implementation is correct? This is my mappings and