hibernate

hibernate see slow query

inside hibernate.property. is that any parameter i can set to see all the slow query that take too much time to return result? i'm using spring-hibernate applicationContext.xml ...

When should we close the EntityManagerFactory?

Hello, I am pretty new on the ORM's. I just start to read books and documents about Java Persistence API with Hibernate. I just wondered, closing EntityManagerFactory is similar with jdbc database connection closing? Should we close it after every persist/update/delete or not? If we don't close it, will the database connection stay ...

Spring @transactional does not start a transaction while testing with JUnit4

I have following configuration. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5....

Hibernate annotations and foreign key relationship

I have a domain object annotated like this for hibernate support. @Entity @Table(name = "INPUT") public class AppInput { /** * Unique id for this request */ @Id @GeneratedValue @Column(name = "INPUT_ID") private long requestId; /** * */ @Column(name = "EMAIL_ID") private String emailId; /** * */ ...

listener failed to start a dedicated server process

my spring-hibernate application run without problem for the past 1 week, but suddenly i get below error. will this caused by configuration error in applicationContext.xml? there is no error on my oracle10g log files (i get below errror every 1-2weeks once) 28 Jul 2010 14:20:19,177 INFO [http-2020-19] - Loading XML bean definitions from...

How to make DB return different rows for subsequent transactions?

I have the below flow in a multi-threaded environment start transaction read n number of top rows (based on a column) from db check some criteria update those set of rows commit/rollback the transaction I am using optimistic locking to handle multi-threaded scenario, but in above situation DB is always returning the same set of rows ...

Why does the org.hibernate.JDBCException not print the sql statement in a stacktrace

When an org.hibernate.JDBCException occurrs (or a Subtype of this Exception) the sql statement is not visible in the Stacktrace. For Example if i execute the following SQL statement with hibernate (on an Oracle DB which does not have a table or view 'nonexsiting'): session.createSQLQuery("select * from nonexisting").list(); i get th...

Hibernate mapping for ternary association fails to delete table rows

Hi there, I'm pretty new to hibernate and this is my first posting in here. I want to create a mapping for a somehow complex scenario and I just don't get it. I have a 'group' entity where I want to store information about 'orgUnits' and 'divisions', a group member has access to. One group can contain zero to many orgUnits and the orgU...

Paging With a Cartesian Product

Please do add a comment if more information is needed to answer this question. We have a query that returns a cartesian product. Since there are a lot of results, there are potentially a ton of objects that get hydrated. We'd like to do simple paging on the database end so it's fast, and so it only pulls n results starting at row n*pa...

Best way to fetch one readonly fields from joined table?

Many times we need only one readonly field from a joined table. e.g, in following case I need only (customer)name from Customers table.For this I am creating entire Customer object, that is consisting of tens of other properties that I don't need in Orders. This issue becomes more significant if such field is being fetched for child clas...

what's the default size of hibernate.jdbc.fetch_size?

We know by default, most of jdbc drivers' fetch sizes are 10. does anyone know what the default fetch size in hibernate, namely hibernate.jdbc.fetch_size is? ...

documentation - is it a template?

Hi, I see that many sites are using the same template of documentation: PrettyFaces Hibernate and more. Is it a template that I can download somewhere? It's so clear! ...

Most efficient way to count rows of a query

I'm using Hibernate to retrieve the number of rows for a specific query. Let's say I have a table called 'Person' with various columns. One of those columns is 'name'. If I wanted to get the number of people with the name of 'Andrew', which of these ways would be most efficient? Assuming there is a performance difference between some...

Using Hibernate to Join to Tables

I am creating an application where people will be able to post comments or articles, and users will be able to rate whether or not the article was helpful to them or not. I currently have two Entities that look like this (non-pertinent details omitted): Article.java @Entity Article @Id private int article_id @ManyToOne @JoinColumn(...

How to retry a lock wait timeout using java persistence?

I need some clarification on the right way to retry a "retryable" exception (e.g. something like lock wait timeout) when using java persistence. For example, with pseudocode like: EntityTransaction tx = em.getTransaction(); tx.begin(); for (a bunch of objects) { em.persist(object); } tx.commit(); I sometimes get an exception thrown...

Should I use Hibernate with this multi-threaded architecture or abandon it?

My software uses multiple threads to do its work. There is a pipeline that looks something like this: +-----------------+ |+-----------------+ +------------+ ||+-----------------+ +------------+ | | ||| | | | | Get and | ||| Worker Threa...

I want to delete record(s) from child table after calling save/update on parent using hibernate

I want to delete record(s) from child table after calling save/update on parent using hibernate ...

NHibernate CreateCriteria query problem

I hope someone can help with this please. I am trying to query an OLAP Fact table with NHibernate, but am struggling to get it to work. Its seems a simple requirement but I just cant see what the problem could be. I have a central Fact table with several Dimension tables, one of the Dimensions has a secondary Dimension. So ERD is. Fa...

Relationship with multiple Entity

I would like to know if it's possible to create a relationship with an entity using hibernate. In one of my models like: public Entity associated_model; public Long associated_model_id; I would like to establish a relationship table with multiple kind of objects by storing their entry id and a model id or name. I'm trying to do tha...

Nested Select Using HQL

Hi, I would just like to know if derived queries can be handled by HQL? I have this bit of code right here and it kept on saying that it did not expect the '(' symbol right after the first FROM keyword. Your help will be much appreciated. Thanks. "SELECT new " + Distribution.class.getName() + " (adhoc, deployment, design, development, "...