hibernate

Batch inserts with JPA/EJB3

Does JPA/EJB3 framework provide standard way to do batch insert operation...? We use hibernate for persistence framework, So I can fall back to Hibernate Session and use combination session.save()/session.flush() achieve batch insert. But would like to know if EJB3 have a support for this... ...

What caching model/framework with Websphere Spring Hibernate Oracle?

We are looking at implementing a caching framework for our application to help improve the overall performance of our site. We are running on Websphere 6.1, Spring, Hibernate and Oracle. The focus currently is on the static data or data that changes very little through out the day but is used a lot. So any info would be great. I ha...

Hiberate problems, jdbc IDENTITY_INSERT is set to OFF

I am getting JDBC error when I attempt a commit through hibernate to SQL Server Cannot insert explicit value for identity column in table 'Report' when IDENTITY_INSERT is set to OFF I am using mappings generated by netbeans that contain, <class name="orm.generated.Report" table="Report" schema="dbo" catalog="DatabaseName"> <id...

Is there a good reason to configure hibernate with XML rather than via annotations?

I've been using Hibernate for a few years but have only used it with annotations, and by setting the connection parameters in my code. Am I "missing something" by not using the XML files? Are there important capabilities available only in XML? Are there situations or patterns where it makes sense to use the XML? ...

Hibernate like layer for C++

Using a DB with C++ is a real mess and it was refreshing when I moved to Java to be able to use a unified system to abstract the whole layer away (aka Hibernate). There are a couple of C++ abstract layers for DB's out there but they are usually vendor specific and only a thin layer that wraps the real C API. Has anybody come across some...

Using a CASE statement in HQL select

Is there any way to do the following in HQL: SELECT case when flag = true then SUM(col1) else SUM(col2) FROM myTable ...

Map problem with JPA / Hibernate / PG

I have two entities, Entity1 and Entity2, on a one to many relationship. On Entity1 I have a map which contains entries. The code I use to persist a new Entity1 with some Entity2 on the map is like this: Entity1 e1 = new Entity1(); Entity2 e2 = null; e1.setE2s(new HashMap<String, Entity2>()); for (String key : someKe...

How can I access to the properties of an object list returned by criteria query inside of itself query

Hello, I'm triying to access inside of the properties of an object inside of an criteria query. I have the follows: <list name="locationsNatural" schema="public" table="natural$locations" lazy="false"> <key column="locations_" /> <list-index column="locationsindex_" base="1"/> <many-to-many class="com.idom.dto.estr.Locatio...

What is the best book to learn Spring and Hibernate

I would like to learn Spring and Hibernate in an efficient way. Next weeks, I will have a lot of time to read but I will not be in front of a computer (so it will difficult to read online tutorials for example). So, my question is : what is the best book to learn Spring and Hibernate ? Of course, I know that I'll have to practice a li...

EasyMock and Hibernate Criteria Queries

Hi, I am trying to test a dao method which uses the hibernate criteria API, using JUnit4 and EasyMock 2.4. When I run the test fixture 'testGetAsset' I receive the following exception: java.lang.AssertionError: Unexpected method call add(name=Test): add(name=Test): expected: 1, actual: 0 add(source=GSFP): expected: 1, actual...

JPA not generating "on delete set null" FK restrictions.

I have two related clases JPA-annotated. Alarm and Status. One Alarm can have one Status. What I need is to be able to delete one Status and "propagate" a null value to the Alarms that are in that Status that has been deleted. That is, I need the foreign key to be defined as "on delete set null". @Entity public class Alarm { @Id...

JPA eager fetch does not join

What exactly does JPA's fetch strategy control? I can't detect any difference between eager and lazy. In both cases JPA/Hibernate does not automatically join many-to-one relationships. Example: Person has a single address. An address can belong to many people. The JPA annotated entity classes look like: @Entity public class Person { ...

How are managed the sequences by JPA and Hibernate?

Hi all, I am using Hibernate in my project, and many of my entities use a sequence for their technical keys. For example: @Entity @Table(name = "T_MYENTITY") @SequenceGenerator(name = "S_MYENTITY", sequenceName = "S_MYENTITY") public class MyEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_MYENTI...

Is there a way to map a one-to-one with a where clause?

Please excuse my ignorance on the topic, as I am relatively new to Hibernate / NHibernate, but I have encountered a mapping I can't figure out: This is what my database table looks like: <bincontents> <id>5873715</id> <title>Video Title</title> <sortorder>0</sortorder> <itemid>23079</itemid> <itemtype>VIDEO</itemtype> <...

Hibernate Criteria API - HAVING clause work arounds

I've written a query using Hibernate Criteria API to grab a summation of a particular value, now I need to be able to restrict the result to rows where that sum is greater or equal to a particular value. Normally I would use a HAVING clause in my SQL to do this, but the Criteria API doesn't seem to support that at this moment. In raw ...

JPA/Hibernate maximum number of joins?

Is there a limit to the number of joins permitted in a JPA/Hibernate query? Since Hibernate doesn't automatically join, I have to explicitly specify the joins in my JPA/Hibernate query. For example, person has an address, an address has a state. The following query retrieves person(s) with address and state fully loaded: select p, a, s...

Hibernate session handling in spring web services

I am using spring-ws with Jaxb2Marshaller, PayloadRootAnnotationMethodEndpointMapping and GenericMarshallingMethodEndpointAdapter to configure my web services via the @Endpoint and @PayloadRoot annotations. When I try to use the DAO's of my project I am able to load objects from the database but as soon as I try to access properties ins...

Hibernate equivalent to EclipseLink's batch query hint?

One thing I like about EclipseLink has this great thing called the batch query hint, which I'm yet to find a Hibernate equivalent of. Basically doing a whole bunch of joins gets messy real quick and you end up querying way more data than you necessarily want (remember that if you join person to 6 addresses the person information is retu...

Hibernate daily builds

Are there daily builds of Hibernate that I can download? I need the latest version for a bug fix that isn't in the released versions. I'm currently trying to build the latest version but am running in to all sorts of test case failures. If would be faster if there's a daily build that I just download and use. ...

Hibernate 3.4 with slf4j and log4j

I'm attempting to upgrade from Hibernate 3.2 to 3.4, which apparently uses slf4j. Our project currently uses log4j. So my assumption is that I should be using the slf4j-log4j12 wrapped implementation. The Maven slf4j dependency is: <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1....