hibernate

Hibernate unidirectional one-to-many.i'm a bit confused

Hello guys sorry if the question looks stupid to you. i have 3 tables currency (id | name) language (id| name | description) transaction (id|amount|languageId | currencyid) so i want to insert into the transaction but making sure that it doesn't insert unknown language or currency (meaning it shouldn't insert to messagetemplate if there...

Hibernate-validator: @NotEmpty does not work for null values

Hi all. I have annotated a String field with @NotEmpty tag. When I try to persist the entity with this filed's value "", it works fine. Mechanism detects the validation error and raises an InvalidStateException exception notifying the issue. But when I try to persist the entity with this field's value null, an UndeclaredThrowableExcep...

How To Make Transactions Work In Grails

Summary A parent can have many children. How do you write a service such that, if after adding a parent there is an error when adding a child, the entire transaction is rolled back. For example, add parent p1, successfully add child c1, then when adding child c2 an error occurs, both p1 and c1 should be rolled back. Detailed Problem In...

Using the same service & DAO from two threads

Hi guys, I've made a very simple REST controller method with Spring 3.0.0.RC1 that uses hibernate to perform a query. The query takes about ten seconds to complete. I've made this with intent so that I can fire up two requests to my controller. Then I fire up the two requests, and query in MySQL (my DB backend) "show full processlist",...

How to Configure Hibernate with Eclipse Galileo

Can someone tell me how to configure hibernate (Annotations) with Eclipse? ...

trouble with writing hibernate query

Hiya, I'm sort a newbie when it comes to hibernate so I'm going to try to ask my question as clearly as possible. I wanna execute following query as hibernate query . <sql-query name="updateINFO"> update info set status_id = 2 where pid = :i </sql-query> Now i is a dyn...

TransactionProxyFactoryBean when switching from configuration-based Service beans to annotation based service beans

Hi guys, I read about using <context:component-scan base-package="tld.mydomain.business"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/> </context:component-scan> and annotate my service beans with @Service("myService"), and thought great, I'll do that, since I'm already doi...

sync entitymanager from database

Hi. i have a swing desktop application that use a entitymanagerfactory, but when this application is executed many times at the same time, the diferents entity managers have old data that was modified by others and this changes will not visible until the next entitymanagerfactory... how can i sync in anytime the entitymanager with the da...

hibernate - How to annotate a property as enum with a field

How do I map an enum with a field in it? public enum MyEnum{ HIGHSCHOOL ("H"), COLLEGE("C") private int value; public MyEnum getInstance(String value){...} } @Entity public class MyEntity { @Enumerated(...) private MyEnum eduType; } How do I annotate so that values H, C will be persisted in the database? If I keep @Enumerated(EnumTyp...

Transaction between several DAO layers ?

As shown below, I am accessing a Service layer method inside of another DAO. (Every DAO in the system is implemented using HibernateDAOSupport class) I wanted to rollback the transaction when #1 or #2 (commented in the following code) is failed. But when #2 throws an exception, #1 does not get rolled back and I can see the entries in th...

SQLite dialect error with Hibernate

I have been trying to use the hibernate dialect for SQLite from http://code.google.com/p/hibernate-sqlite/ in a project, but have hit a problem with something like the following... SQLQuery query = session .createSQLQuery("select id from collection where collection = (:collection_name);"); query.setParameter("collection_name", col...

using toplink from hibernate

hi, i am using hibernate but i want to add an application that is using hibernate. the problem that i am facing is when i want to perform global transaction on that combined application. i am using weblogic as container, now the problem is that hibernate created its own connection, i want that toplink should use that connection only... c...

autocomplete text box

i want to make a text box like stackoverflow have for the tag at askquestion page where data pop up as we write something. I want to fetch the tag from the database rather local static data. In my project i am using jsp servlet hibernate and spring Please tell me how to do.. thanks in advance ...

Spring Transactions in diffrent DAOs does not work anyway?

Here is my implementation in summary 1) all DAOs implemented using HibernateDAO support/ @Transational annotation is only used in Service layer 2) Use MySQL / HibernateTransactionManager 3) Test using main(String args[]) method (do transactions work using this method? ) Transactions does not get rollbacked and invalid entried can be...

Criteria Querying question

how to select particular field using Criteria ? ...

hibernate Lazy loading

my hibernate object A has object B, C, and D as properties : A.getB().getName(); A.getC().getTitle(); now, I want to load A with all its properties without getting a LazyInitializationException. so, I need to load A's object graph fully. is there any generic method of retrieving an object's graph in hibernate ? ...

How to retrive data when its hace reference to collection data and this collection have object which is of type collection.

Hi, I am currently writting a piece of code for retrive data using hibernate with the criteria APi. I have one class-A This class have one property CollectionOfB; This collection collection contain object of another class that is class B. Class B have one property CollectionOfC; This collection collection contain object of another cl...

OptimisticLocking and @OneToMany(mappedBy=...) handling?

I have an AbstractEntity class as superclass for all my entites that defines an optimistic lock column like this: @Version private long lockVersion; Now I often get OptimisticLockingExceptions on entities, that are only changed in one the mappedBy relations similar to the following: @OneToMany(mappedBy = Property.PROPERTY_DESCRIPTOR,...

hibernate property formula how to get more than 1 row?

In the hibernate mapping file I use property formula to get any value. <property name="price" type="double" formula="(select SUM(amount) ...) /> But it allows to get only 1 row. How can I get lisf of rows? I understand that "property" is not suitable, but it's impossible to add formula to set or list. Of course I just want to get va...

hibernate how to retrieve a hierarchy object

Hi all, I have the following beans Task, ServerDetails and ApplicationDetails. I wish to retrieve all tasks, their server details and application details based on a specific application name. From the result i expect to be able to retrieve the data in a manner such as: task.getServers().getApplicationDetails() In actuality, I get wha...