hibernate

could not read column value from result set ; String index out of range: 0

Hello ! I'm reading data from a table( from a MySQL Database) with Hibernate SQL Query. The thing is, the table contains a colum that is mapped to a char in Hibernate Model, and sometimes this column is empty. And I suppose this is where my exception comes from. How can I map a colum of char to my hibernate model without getting this err...

How to transfer data from one database to another with Hibernate?

I have an application A with a domain-model which is mapped to a database using Hibernate. I have another application B that uses exactly the same domain-model-classes as A and adds some additional classes. My goal is to read data from database A in application B and transfer that data into the database of B (to make a copy of it). In ...

What is the role of Spring in Struts + Spring + Hibernate?

What role is Spring taking in Struts + Spring + Hibernate? ...

Spring: Obtaining ResourceBundle based on MessageSource

I'm using hibernate validator framework with Spring. A class implementing the Spring Validator validates objects with Hibernate's ClassValidator. To localize ClassValidator's error messages I need to pass a ResourceBundle into the class' constructor. My ApplicationCountext has a MessageSource bean (ReloadableResourceBundleMessageSource) ...

Is there a more efficient way of making pagination in Hibernate than executing select and count queries?

Usually pagination queries look like this. Is there a better way instead of making two almost equal methods, one of which executing "select *..." and the other one "count *..."? public List<Cat> findCats(String name, int offset, int limit) { Query q = session.createQuery("from Cat where name=:name"); q.setString("name", name);...

Add (external) relationship (tagging) to existing Hibernate entities

I need to add a new many-to-many relationship to an existing Hibernate entity. I do not want to touch the original Hibernate entity bean or its configuration. What I am adding is a "tagging" feature that can be viewed as an external contribution and not part of the entity's data itself. I want to have a simple join table with only two c...

Hibernate mappings with a discriminator

I have a table with one field that can point to a foreign key in one of 3 other tables based on what the descriminator value is (Project, TimeKeep, or CostCenter. Usually this is implemented with subclasses, and I am wondering if what I have below will work. Note the subclass name is the same as the parent class and the noteObject prop...

Fix for Hibernate error "Use of the same entity name twice"

How you fix the following Hibernate error: What does "Use of the same entity name twice". ...

Unmanaged Threads Spring Quartz Websphere Hibernate

It appears that our implementation of using Quartz - JDBCJobStore along with Spring, Hibernate and Websphere is throwing unmanaged threads. I have done some reading and found a tech article from IBM stating that the usage of Quartz with Spring will cause that. They make the suggestion of using CommnonJ to address this issue. I have ...

What is a good design for a query "layer" for Java JPA

In JPA the Entities are nice annotated Plain Old Java Objects. But I have not found a good way to interact with them and the database. In my current app, my basic design is always to have a sequence based id as primary key so I usually have to look up entities by other properties than PK. And for each Entity I have a stateless EJB of ...

Why does Hibernate try to delete when I try to update/insert?

In my app I have these Hibernate-mapped types (general case): class RoleRule { private Role role; private PermissionAwareEntity entity; // hibernate-mapped entity for which permission is granted private PermissionType permissionType; // enum @ManyToOne @JoinColumn(name = "ROLE_ID") public Role getRole() { return role; ...

Strange Hibernate Cache Issue

Hello We are using Hibernate 3.1 with Spring MVC 2.0. Our problem occurs when data is updated on the database directly (not in the application). We use a Filter to filter a collection of results by whether the orders are opened or closed. If we change an order on the DB to be closed, the filter returns the correct list, however, the ...

How to Serialize Hibernate Collections Properly?

I'm trying to serialize objects from a database that have been retrieved with Hibernate, and I'm only interested in the objects' actual data in its entirety (cycles included). Now I've been working with XStream, which seems powerful. The problem with XStream is that it looks all too blindly on the information. It recognizes Hibernate's ...

Spring + Hibernate: how to have a configurable PK generator?

We use Spring + Hibernate for a Webapp. This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel. What I need to do, is to make sure that the Persons generated on these two unrelated production sites all have distinct PKs, so that we can m...

Hibernate: comparing current & previous record

I want to compare the current value of an in-memory Hibernate entity with the value in the database: HibernateSession sess = HibernateSessionFactory.getSession(); MyEntity newEntity = (MyEntity)sess.load(MyEntity.class, id); newEntity.setProperty("new value"); MyEntity oldEntity = (MyEntity)sess.load(MyEntity.class, id); // CODEBLOCK#1 ...

UserType join in Hibernate

Is it possible to make hibernate do "the right thing" for some value of "right" in this situation? from ClassA a, ClassB b where a.prop = b.prop The thing is that prop is a UserType with different representation in the joined tables. In table A it is represented as an integer and in table B it is represented as a char. So the eq test ...

Where (which layer) to put Entity query methods, "persist" methods etc. ?

Hi, I have a SEAM app with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods. The default choice seems to put them in a session bean layer with injected @PersistenceContext(...) @Inject EntityManager entityManager; But I think I would rather have the methods on the entities themselves. What ar...

What is the best practice for JPA/Hibernate entity classes and synchronization?

It seems like most examples of JPA/Hibernate entity bean classes I've seen do no explicit synchronization. Yet, it is possible to call getters/setters on those objects in the context of building up a transaction. And it's possible for those methods to be called across multiple threads (although maybe that's unusual and weird). It se...

Is there a role for a DBA when an app uses a persistence layer or repository?

I'm taking on the re-architecting of a pair of applications which use Hibernate in one case, and a combination of Hibernate and a Java Content Repository (specifially JackRabbit) in the second. A key issue in the rearchitecting is to improve performance, so I'm wondering whether there's any value in bringing in a DBA for the design and ...

How to connect my Spring + Hibernate based application backend with pure HTML and AJAX based client?

Hi all, I'd like to call methods of my DAOs by AJAX. I'm quite new in that so I would like to ask what is the best way to do that. Is it possible to publish my beans as web services and call them with e.g. jQuery? I think it is not possible :) I've also read about Direct Web Remoting but I don't know which way to go... As I see, there...