hibernate

using multiple table in hibernate, problem with output

I am using following query from A as a,B as b,C as c where a.val='1' and b.val=a.val and c.val=b.val Now if i do follow query.list(); what will be the output? Also if I want to get the output of above query what else I have to do? ...

[Hibernate.Envers] @ManyToMany: REVTYPE is only ADD

Hi, i have the two classes Person and Attribut, in short: @Entity @Indexed @Table(name="persons") public class Person { private int id; private List<Attribute> attributes; @Id @DocumentId @GeneratedValue @Column(name="person_id") public int getId() { return id; } @ManyToMany @JoinTable( name="attribute_all...

Hibernate JPA, Spring MVC and LazyInitializationException

Hi All When trying to get items from db, I got this error: 13:00:13.876 [7838526@qtp-204712603-0] ERROR o.h.LazyInitializationException - failed to lazily initialize a collection of role: bo.myobj, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.myob.linke...

Converting Between Hibernate Collections and My Own Collections

I have set up Hibernate to give me a Set<Integer> which I convert internally to and from a Set<MyObjectType> (MyObjectType can be represented by a single integer). That is to say, When Hibernate calls my void setMyObjectTypeCollection(Set<Integer> theSet) method I iterate through all the elements in theSet and convert them to MyObjectTy...

Hibernate setParamater a class

I am new to Hibernate. I want to create a public Object getById(Class class,long id) function. I tried creating query like: from :nameEntity where id= :id but I'm facing problems when setting parameter for nameEntity. Hibernate doesn't recognize it as a parameter. I used session.createQuery function. Could you please help me? ...

Only one of "create" or "delete", in parent child association, works at a time

I am trying to implement parent child relation on traditional Order and Items tables. For this I am using uni-directional one-to-many association but I can make either "save" operation work or the "delete", one at a time. If I set inverse="false" I can create new order (with items) but can't Delete it because hibernate tries to delete o...

Grails and Amazon SimpleDB

How to setup Grails project to use Amazon SimpleDB? One possibility is to install gorm-jpa plugin and use SimpleJPA library, but I couldn't setup it correctly. Has someone experience with this combination? ...

IntelliJ IDEA Hibernate

I'm learning hibernate and I am running into some issues. The book i'm reading is Harnessing Hibernate - Oreilly. They explain everything using ANT, but I'm not really in the moood for the hassle to write such a huge build.xml. So I'm trying to get it to work with IntelliJ. I managed to make a mapping according to a DB table in my MySQL...

Hibernate getHibernateTemplate issue when saving object inside another object

I recently changed my code to make reference to the getHibernateTemplate(), and now my forms don't seem to save correctly, here's the code: public void saveForm(EcoFormFill form, int userId) throws RemoteException { User tmpUser = (User)getHibernateTemplate().load(User.class, new Integer(userId)); form.setUser(tmpUser); ...

Native SQL query for an Hibernate entity using @Formula results in NullPointerException

I've got an simple Hibernate entity for which I use the @Formula annotion: @Id private Long id; private String name; @Formula("(select count(f.*) from foo f where f.id = id)") private long bar; When I try to load an entity with a native SQL Query: EM.createNativeQuery("SELECT f.*, count(something) as bar FROM foo f WHERE f.name...

What is the difference between @ManyToOne(optional=false) vs. @Column(nullable=false)

In JPA, I am confused when to use the attribute optional=false and the annotation @column(nullable=false). What is the difference? ...

Can't create a Many-To-One relation with all-delete-orphan cascade. MySQL says a foreign key constraint fails when deleting the parent.

Hi, I started using Hibernate recently and I'm still a newbie, however, the error I'm facing doesn't seem to be simple. My current environment is: Windows 7 MySQL 5.1.49-community mysql-connector-java-5.1.13-bin.jar hibernate-distribution-3.6.0.Beta1 I'm following the "Hibernate in Action" book and did everything exactly the way...

J2EE Struts,Spring and Hibernate Framework problem

i am going to develop a web application using Struts,Spring and Hibernate. But i have no idea about any of them. Even i know little about JSP and nothing about Servlet. So my question is what to do? I have to learn all those things. But i don't have much time. Normally to learn something i read books on that topics or use tutorials. Now ...

Is it possible to search for same value on multiple columns with Hibernate Criteria?

I have search query that has many optional parameters and then search word field that searches many columns. Is it possible to use hibernate criteria for this purpose? I need to search many columns with same search word. Example code (what is not working correctly) if(isNotEmpty(searchWord)) { criteria.add(Restrictions.like("descri...

Hql statement not returning distinct values when specified.

Hello experts! As the title states I have some issues with my hql statement. I have two entities: SecondEntity: public class SecondEntity implements Serializable { @Id @GeneratedValue private Long id; @ManyToOne @JoinColumn(name = "firstEntityId") private FirstEntity firstEntity; @NotNull(message = "the b...

hibernate locked table

Why is this giving me a lock timeout: for(int i = 0; i < playersCount ; i++) { StatUser stats = (StatUser) selectedUsers.get(i).getStatUsers().iterator().next(); int gc = stats.getGamesPlayed(); int gm = stats.getMakeCount(); Session session = HibernateUtil.getSessionFactory().getCurrentS...

Which Hibernate compatible database to use for Java Swing application?

I will be implementing a java swing app. At first, I wanted to use apache derby db, because I needed embeded db. But it turned out that it does not plays nice with hibernate (https://forum.hibernate.org/viewtopic.php?f=6&amp;t=1003258&amp;p=2433546#p2433546, http://stackoverflow.com/questions/3322575/netbeans-derby-hibernate). Hiberna...

Using Hibernate between different threads,JVMs and servers

Hi, I'm working on a system which has a 4 modules, each working on its own server and each should be able to clustered. What I basically need is to have the ability to work on the same entities on the different modules and have them update appropriately when changes occur on different threads,JVMs and servers. I've heard, mostly as a b...

Does the ModelDriven interface poses a security explot in struts2?

background: I coded a struts2 ActionSupport class with ModelDriven. It's a hibernate/spring web app, using OSIV and attached entities in the view (JSP). I received this email today from the architect 'punishing' me for putting an object that had a reference to an attached entity on the struts2 valuestack via the ModelDriven<E> interfa...

How to persist entity with two parents using hibernate and web service?

I have the following entity structure (A, B, C, D are entities): A-> one-to-many B, A-> one-to-many C, B-> one-to-many D, C-> one-to-many D. I want to persist entity A with hibernate but I am sending it over web service (cyclic references are eliminated). So, on the server I receive parents that “know” about the children and childre...