hibernate

In Hibernate, is there any difference between session.get() and session.load() besides how bad IDs are handled?

An application I'm working on does all its queries by identifier using session.load(). Given the chaos it causes when it can't find the identifier and throws an exception, I'm thinking of swapping it over to session.get(). But before I do that, it's such a fundamental part of the system that I want to make sure there's absolutely no othe...

Hibernate transaction problem

When I execute some queries inside Hibernate transaction -> the data successfully updated in my mysql, but in my application there are still old values. When i restart - it`s Ok. If i set autocommit mode - works fine, but i have to use transaction ;-). Any ideas? Thanks in advance. ...

hibernate Lock wait timeout exceeded;

I am using hibernate, trying to simulate 2 concurrent update to the same row in database. Edit: I moved em1.getTransaction().commit to be right after em1.flush(); I am not getting any StaleObjectException, the two transactions committed successfully. Session em1=Manager.sessionFactory.openSession(); Session em2=Manager.sessionFactory....

Why I have to declare each and every class in my hibernate.cfg.xml when using annotations?

Why it isn't enough to set the @Entity annotation? Am I missing the point here (performance?)? Thanks. ...

problem persisting xml in Mysql using hibernate

Hi, I am trying to persist a string object in Mysql(5.0.67) using hibernate. My entity is as follows: @Entity @Table(name = "info", schema = "DB") public class info { @Column(name = "InfoXml") private String InfoXml; } The problem is when I persist the xml with value: String InfoXml = "<?xml version="1.0" encoding="UTF-8" standalon...

How similiar are the implementations of hibernate and nhibernate?

How similiar are the implementations of hibernate and nhibernate? i.e. if I am comfortable with nhibernate, will hibernate be a very easy transition? ...

Is there a way in Hibernate to set not-null to true on save but not delete in a mapping config?

<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; <hibernate-mapping package="org.lexiclan.orm.dao"> <class name="Address" table="ADDRESSES" lazy="false"> <id name="addressId" column="ADDRESS_ID"> <generator...

Hibernate Search querying ?

Greetings My domain model is as follows class Species { private String name; .. .. List<Family> families; } class Family{ private String name; private String locusId; .. List<Member> members; } class Members{ private String name; private String repTranscript; } I want to use 'Hibernate Search' to execute queries like o...

which SessionFactory should be use for transactionManager?

<bean id="projectService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager"/> <property name="target"> <bean class="com.company.project.company.services.ServiceImpl" init-method="init"> <property name="HRappsdao" ref...

Spring jta-transaction-manager

Using Spring: can jta-transaction-manager use id as name so that I can pass it as REF to my service layer like below? is tx:jta-transaction-manager can only be used for je22 container? I mean for Tomcat, I need to do it manually, like below: <tx:jta-transaction-manager id="name_transactionmanager"/> &lt;bean id="projectService" clas...

spring hibernate configuration using resource_local or jta by default?

may i know as my configuration is done directly on applicationContext.xml, i do not have persistence.xml . by default this is resource_loca or jta? do i need to add extra parameter if i want to use jta? <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"...

How to define column that is not actually related to another table by keys, but by keywords

I am using JPA to see how helpful it will be, rather than using straight SQL, and I realized today that one of my columns is incorrect. I have a playlist application. Each playlist has a title and a list of keywords that signify the songs to include. So, I may have this as one row, where there are three keywords. Exercise steady...

Mapping Relationships with Hibernate

I'm still learning how to set up these mappings using the JPA annotations so this may be a beginner mistake. I have a User class and a Course class. In the database each Course has a User foreign key in each row (think of the User as the teacher teaching the Course). So each User can have multiple Courses, but each Course has only one U...

drools persistence with mysql, can't get process instance.

I'm stumped. I'm trying to implement persistence with Drools-flow, and I'd like to grab the value of a property on a workitem / processinstance, but everytime I try to get the workitem or process instance I end up with the stack trace below. I'm walking through the source and from what I can tell, this happens anytime I try and grab a ...

hibernate - projection a component

I have a Address bean that have a LatLng component. Please tell me how can i project that component and transform it in to a new class. Thank you. ...

Hibernate 2nd level cache objects that are lazy=false, result in a default fetch=join, is it documented anywhere?

I experience the following apparently undocumented issue, and I want to understand if I did something wrong Did anyone encounter the same issue? Is it really not documented anywhere? or did I miss something? The behavior is this Assume the following mapping <class name="org.sample.Foo" table="foo"> ... <many-to-one name="bar...

Why hibernate session.close() does not flushes the data automatically?

When hibernate closes a session, the purpose of close is basically to close the underlying connection and the clean up the first level cache. Why the flush also does not happens automatically here? ...

Web architecture: MVC, Lazy initialization, Data transfer Objects, Open Session In View, is there a concensus approach?

What flaws do you see in the following design, (and what would be your ideal architecture suggestion) for a typical web 3-tier application? My current blueprint approach is very roughly this (assuming Java, Spring, Hibernate, JSP) Controller Stateless, potentially wrapped with a read only transaction (to avoid lazy init exceptions),...

Hibernate Criteria / Query on object properties

I have a class AppUser; class AppUser { private String firstName; private String lastName; //-- getters and setters } I also have another class Student; class Student { private AppUser appUser; private Date dateOfBirth; //-- getters and setters } How would i search for Student John Doe, firstName John, lastName Do...

java web applicaton layout, please explain some design principles/patterns

I'm looking at this java web application that is using hibernate, jsp's, and spring framework. (from what I can tell!) the file layout is like this: classes/com/example/project1 inside project1 /dao _entity_Dao.java /dao/hibernate/ _entity_DaoHibernate.java /factory DaoFactory.java DaoFactoryImpl.java /managers ...