hibernate

Hibernate + Spring using multiple datasources?

I'm working on a web application that uses Spring MVC 2.5 and Hibernate. One of the requirements of the application is that it must be able to export some objects to an external database. I figure I might as well use my existing data layer and just save the objects to the external source. I'm new to Spring and Hibernate, and I guess I...

Obtaining an object state

Does hibernate provide a method that returns an object's state (transient, persistent, detached)? ...

hibernate: retrieving orphan children

I have a unidirectional one to many relationship, and would like to select all children who have no parent. How can this be done in HQL? 10x ==== i.e. Parent: id, name, ..., Collection<Child> Child: id, name ...

Ordering By Mapping Table Value in Hibernate

I have a @ManyToMany mapping where the table self-references through a mapping table, and we want to order on an order id in the actual mapping table, but are finding it difficult to configure this. We could perform it in hibernate xml, so it is natural to assume the support is there in JPA annotations. Does anybody know how we can orde...

From Computer Scientist to Software Engineer

Hello Stackoverfellows, I graduated in December in Computer Science and have acquired a Software Engineering position. I have been banging my head up against the wall for 2 months trying to learn Hibernate, Spring and everything else that has been thrown at me in my first project. Prior to accepting this job I had experience only in pr...

RESTFul and Hibernate

Is there a tool that can create RESTFul java services from classes generated with hibernate tool? ...

HQL: order all items by a specific item in its map

Hi, I am quite new to Hibernate and currently struggling a bit with HQL. I have the following mapping and would like to get all "Industry" entities ordered by the "translation" for a given "culture_id" Code: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Domain.Industr...

hibernate order by association

I'm using Hibernate 3.2, and using criteria to build a query. I'd like to add and "order by" for a many-to-one association, but I don't see how that can be done. The Hibernate query would end up looking like this, I guess: select t1.a, t1.b, t1.c, t2.dd, t2.ee from t1 inner join t2 on t1.a = t2.aa order by t2.dd <-- need to add this ...

Is it possible to generate JPA entity classes from a database schema at runtime?

IDEs like Netbeans allow generation of entity classes through a persistence context. If you had access to underlying generation method (not sure if it is an external tool or part of the IDE), could you generate database entity classes dynamically at runtime? The idea being that you could hook into the entity classes using reflection. I ...

Is it possible to use more than one persistence unit in a transaction, without it being XA?.

Our application needs to use (read-only) a couple different persistence units pointing to different databases (different, commercial vendors as well). We do not have the budget to enable 2pc on one of them (Sybase). Is there a way to use these in a transaction without it having to be an XA transaction? We're using Websphere 6.1, Sybas...

Java JPA Polymorphic mapping on Many to One

I am trying to map a JPA (using Hibernate now) Many-to-one relationship with a polymorphic type, but I am having no luck. I don't see why it isn't possible, or why I would be forced to declare a concrete type in the mapping. Here is an example: @MappedSuperclass class BaseClass { @Id long id; } class ClassWithList extends Base...

Hibernate + Swing

What's the best practice? A single session for the whole app A session per window A session per thread, and detaching everything at random Something else? I've googled around, and there's no consensus. Everyone says something, and then takes it back. I find lugging a session around stupid... So, what's the deal? ...

Hibernate mapping and inheritance issues with @SecondaryTable

I have a pretty simple class hierarchy structure that is listed below, each sub class having a @DiscriminatorValue enumeration type, which works very well. Abstract class: AbstractNode (abstract class mapped to the Node table) Subclassed classes: FieldNode (simple class mapped to Node table as well, but with different @DiscriminatorV...

EntityInterceptor

Hi all, i need to put some code in the EntityInterceptor, but when i try to recover collections asociated with my object (aggregations) i can't, is like Entity doesn't take care about collections . Why? Thx ...

To Lazy Load or not in effort to improve performance

It has been suggested that in order to improve performance of our system that the use of lazy loading should be used across the board. That is to change the OneToOne mapping with the “mappedBy” property to the @OneToMany mapping. This is to address and stop the loading of unwanted data from the database which leads to slowness of the a...

Hibernate for getting a list of primitive integers for subselect

Isn't there a way with Hibernate to return a list of (primitive) values from one column in a table? I need this for a subselect where I only want rows where a particular field is not in a list of ids from another table. ...

OAS 10.1.3.1 not posting CLOB datatype using Hibernate and XA

I am running a J2EE application on Oracle Application Server 10.1.3.1 that will save to 2 Oracle databases (9i and 10g) within the same method in some cases. In order for this to take place, we are using XA drivers for both data sources and Hibernate to abstract the integration layer. Hibernate sessions are singletons and are owned by ...

How can I pull objects out of hibernate and into memory. I'm hitting session problems.

Hi, I have a rather enormous project in which I'm trying to retrofit in-memory data. Essentially, I have a big collection of objects which contain primitives and other objects which exist in hibernate. Large sections of non-dao code rely on lazy-loading through hibernate to hydrate objects on the fly. However, since everything exists in ...

manual initialization of required Hibernate database tables

I'm getting started in Hibernate and so far it's not too hard. But I am confused about the hbm2ddl.auto property. Is there a way to manually execute whatever this does to initialize the database tables? I only want to do this after I make my database changes, not every time I run my program. edit: what about at runtime? is there a way i...

Extending JPA entity data at runtime

I need to allow client users to extend the data contained by a JPA entity at runtime. In other words I need to add a virtual column to the entity table at runtime. This virtual column will only be applicable to certain data rows and there could possibly be quite a few of these virtual columns. As such I don't want to create an actual add...