hibernate

Hibernate: Enabling lazy fetching in Criteria API

I am writing a query against a domain model where (for whatever reason) a one-to-many association is mapped with lazy="false". In my particular query, I'd rather fetch that collection lazily, because I don't care about its contents. How can I reenable laziness for my particular query? Is this possible at all? So far, I looked at Criteri...

Creating field with reserved word name with JPA.

@Column(name="open") Using sqlserver dialect with hibernate. [SchemaUpdate] Unsuccessful: create table auth_session (id numeric(19,0) identity not null, active tinyint null, creation_date datetime not null, last_modified datetime not null, maxidle int null, maxlive int null, open tinyint null, sessionid varchar(255) not null, user_id ...

Using Hibernate to do a query involving two tables

I'm inexperienced with sql in general, so using Hibernate is like looking for an answer before I know exactly what the question is. Please feel free to correct any misunderstandings I have. I am on a project where I have to use Hibernate. Most of what I am doing is pretty basic and I could copy and modify. Now I would like to do some...

Hibernate Computed Criteria Order

I have an Oracle XMLType column that stores the various language specific strings. I need to construct a Hibernate criteria that orders on this column. In order to do this, I need to extract the value with an Oracle function. This criteria is generated automatically by code I have written but I cannot, for the life of me, figure out how ...

Display results from solr with JSP

Hi, I am trying to work out the best way to display solr results in JSP. I am a bit new to JSP but it seems as if there are a whole bunch of ways of doing it e.g. Hibernate, Spring MVC, JSP page itself, struts. It would be great to find out if anyone has any experience with consuming Solr or XML and which of the above solutions is th...

Joining multiple result set

I am trying to develop a Java application which merges data from multiple data source basically RDBMS. The scenario is some thing like this. I have creates a connection to two data sources, lets say a MSSQL database and other Oracle. Also on each connection a user can create a DataObject( a Java object) which contains a SQL query and a ...

DbUnit: problem with increment id generation

I am using DbUnit together with Unitils, which works great most of the time. Today I found a strange problem. Situation is: I use Hibernate, and have id with "increment" generator: <id name="Id"> <generator class="increment"/> </id> I prepare test dataset, where maximal id is 5. I use clean-insert loading strategy. I ha...

How to correctly implement OpenSessionInView with Spring 3.0 and Hibernate 3 (in liferay portlets)?

Hello, I have some problems in implementing the OpenSessionInView pattern. From various resources on the web i configured my application in this way: 1) in my dispatcher-servlet.xml I have an interceptor that should get all my requests with a spring class OpenSessionInViewInterceptor: <bean id="urlMapping" class="org.springframework....

Nhibernate multiple component properties of the same type in a class

I have a class LINE which contains two properties of type POINT. I would like POINT to be a component property. If LINE were to contain only 1 POINT, this would be no problem, but since it contains 2 POINTs I would think I needed to distinguish them (so a prefix or suffix can be applied to column names). I tried using the PropertyName a...

Custom messages in Hibernate Validators

link text following this link i can get the custom messages but from properties file. what if i need same from class i mean some thing like.. public class Messages_en_US extends ListResourceBundle { @Override protected Object[][] getContents() { labelsArray = new Object[labels.size()][2]; int counter = 0; ...

JPA : optimize EJB-QL query involving large many-to-many join table

Hi all. I'm using Hibernate Entity Manager 3.4.0.GA with Spring 2.5.6 and MySql 5.1. I have a use case where an entity called Artifact has a reflexive many-to-many relation with itself, and the join table is quite large (1 million lines). As a result, the HQL query performed by one of the methods in my DAO takes a long time. Any advice o...

how to get the hibernate mysql database connection to android emulator

hi i new to android developer. how connect mysql web server database in android emulator. my web application database is connect by hibernate in struts2 application. so please help me and send some code for struts and android application code ...

Hibernate hbm2ddl and SQL Server: Long as column of numeric data type

Hibernate generates column of type “numeric” in SQL Server for properties of type Long of Java class. Is there a way to make Hibernate generate bigint (or int) column instead of numeric using the Hibernate hbm2ddl? ...

Is it possible to create indices on join table using Hibernate annotations and hbm2ddl?

I have a two entities in many-to-many association. Hibernate creates a join table for this association if hbm2ddl is activated. However, since I do not have an entity for this table, I can not apply @Index annotation. Is there a way to tell hibernate hbm2ddl to generate indices and primary key on the join table? ...

How do I prevent Spring/Hibernate from automatically committing my modifications to the database?

Hello Overflowers, I am working with Spring and Hibernate. I have an object which was retrieved from the database with HibernateTemplate. When I modify this object Hibernate is making inserts into the database before the data is ready to be inserted, the result is a lot of database errors along the line of "cannot insert NULL into ......

How do I get the Hibernate reverse engineering tools to generate <bag> or <list> for inverse associations?

I want to add elements to a collection that ends up getting mapped like this: <set name="others" inverse="true" lazy="true" table="other" fetch="select"> <key> <column name="otherId" not-null="true" /> </key> <one-to-many class="my.pkg.OtherEntity" /> </set> I'd like Hibernate to use instead, because I don't care about the ...

Designing objects for Hibernate

I need some help with a design problem. I'm having trouble wrapping my head around how to design an object (or maybe multiple objects) so that I can query the way I would like to. Let me start by showing a sql query that returns exactly the information I want: select distinct rights_table.receiver_guid, user_info.name from rights_tabl...

How do you bulk delete records in Grails/GORM?

I have a table which has records that need to be periodically cleared according to a set of criteria. I was expecting that I could use the criteria builder to just delete the records, but that fails because there is no delete method on criteria... def c = Agency.createCriteria() c.delete { eq("agency", "XXX") } So I thought may...

When does retrieving a Hibernate proxy's id initialize the proxy?

In Hibernate when you retrieve an Entity via a load, if you access that Entity's id accessor it does not initialize the proxy: Property myProp = (Property) session.load(Property.class, myId); myProp.getId(); // Doesn't load the proxy myProp.getDescription(); // Loads the proxy from the database hit However, I am unclear what the rule...

Hibernate Mapping Through Another Entity

Consider this simple database schema: User Course StudentCourse Student +-------------+ +-------------+ +-------------+ +-------------+ | -user_id |1 *| -course_id |1 *| -course_id |* 1| -student_id | | |---->| -user_id |---->| -student_id |---->| | +--...