hibernate

Problem using Hibernate Projections

Hello! I'm using Richfaces + HibernateQuery to create a data list. I'm trying to use Hibernate Projections to group my query result. Here is the code: final DetachedCriteria criteria = DetachedCriteria .forClass(Class.class, "c") .setProjection(Projections.projectionList() .add(Projections.groupProperty("c.id"))); .....

Hibernate Collection chaining

I have two Entities University courses Course students i want to access all the students in a university. I tried the following query select u.courses.students from university u i got the following exception. org.hibernate.QueryException: illegal attempt to dereference collection [university0_.id.courses] with element p...

@OneToMany property null in Entity after (second) merge

Hi, I'm using JPA (with Hibernate) and Gilead in a GWT project. On the server side I have this method and I'm calling this method twice with the same "campaign". On the second call it throws a null pointer exception in line 4 "campaign.getTextAds()" public List<WrapperTextAd> getTextAds(WrapperCampaign campaign) { campaign = em.merge...

How to use JTA support in Tomcat 6 for Hibernate ?

They recommend using JTA transaction support in JEE environment. But how to configure JTA in Tomcat6 so that Hibernate Session could use it ? Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope a...

Best Tomcat6 JNDI + Hibernate configuration for session/transaction support

Quote from hib official docs: Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope and context of a current session. Given the maturity of the numerous stand-alone JTA TransactionManager implementa...

what are good blogs to read relating java, spring, hibernate, maven?

To continue to question further I'm more interested in blogs, websites who once in a while release a tutorial, tip or best-practice on the topics I mentioned. For ex : http://net.tutsplus.com/ is very good website to follow if you wanna learn about or upgrade your knowledge about CSS, HTML, Javascript, PHP .. Is there a website like thi...

Ordering by number of relationships in Hibernate

Hi, I've got two models which have a one-to-many relationship. Lets say its an auction for a product and the product can have many bids. Basically what I'd like to do is pull out all the products but order them by the number of bids they've received. What I've got so far is: "select p from Product as p join p.bids b where b.product=p...

Detecting modfications in the persistent state

Hi, I know that during a update hibernate cand detect if any change has been done. If it is no, no sql request will be done. IS there a way to get this boolean information computed by hibernate ? Thanks in advance Regards ...

Finding users whose birtday is today with JPA

Hi, I have a table with users and are trying to get a list with the people who have birthday today so the app can send an email. The User is defined as @Entity public class User { @Size(max = 30) @NotNull private String name; [...] @Temporal(TemporalType.DATE) @DateTimeFormat(style = "S-") protected Date ...

Entity persist register validation listener

I'm using JBoss 6 with Seam, and I have an entity I am trying to persist, User. I have extended org.jboss.seam.framework.EntityHome to provide a UserHome class and have overridden the persist() method. I have thoroughly annotated my entity class with javax.validation annotations. When I provide valid values for all the fields in my entit...

How do I share a Hibernate SessionFactory across web applications?

I have two web applications that are running on a single Tomcat server and are connected to the same database with Hibernate. I am concerned that having two SessionFactory instances running around might cause some issues. Also, since both web applications share much of the same application logic, I thought it would be a good idea to cen...

Difference between FlushMode.AUTO and FlushMode.ALWAYS in Hibernate?

Have gone through hibernate api specification on FlushMode but didn't get the exact difference. So please help. ...

Customizing detection change

Hi, I can now if a session contain any changes which must be synchronized with the database with session.isDirty() But i have a simple field (modification date) that i would like to be ignore by it. Example: object Person( name,age,datemodification). if i just modify the datemodification field i would like that session.isDirty() or ot...

Default conditions on Hibernate filters

I'm defining a Hibernate filter which specifies a default condition as follows: <filter-def name="IsDeletedFilter" condition="IsDeleted = 'false'" /> Within my entity mapping, I associate the filter like this: <filter name="IsDeletedFilter" /> According to the documentation, the filter should apply the default condition when used t...

Hibernate naturalID

Hibernate doesnt seem to generate a notnull constraint on a field I marked as naturalID. Is this normal? @MappedSuperclass public class AbstractDomainObject extends PersistentObject { @NaturalId private String code; DB Schema: CONSTRAINT SYS_CT_47 UNIQUE(CODE) There is no not null constraint here. ...

Hibernate not using schema and catalog name in id generation with strategy increment

Hi, I am using the hibernate increment strategy to create my IDs on my entities. @GenericGenerator(name="increment-strategy", strategy="increment") @Id @GeneratedValue(generator="increment=strategy") @Column(name="HDR_ID", unique=true, nullable=false) public int getHdrId(){ return this.hdrId; } The entity has the following table...

getting count(*) using createSQLQuery in hibernate?

I have several sql queries that I simply want to fire at the database. I am using hibernate throughout the whole application, so i would prefer to use hibernate to call this sql queries. In the example below i want to get count + name, but cant figure out how to get that info when i use createSQLQuery(). I have seen workarounds where p...

Hibernate or JPA or JDBC or ???

I am developing a Java Desktop Application but have some confusions in choosing a technology for my persistence layer. Till now, I have been using JDBC for DB operations. Now, Recently I learnt Hibernate and JPA but still I am a novice on these technologies. Now my question is What to use for my Java Desktop Application from the fol...

Hibernate: ordering a Set

I have a class Person who has a set of Books. It is not meaningful in the particular case to have an ordered or sorted collection. Say now that I have a search page with a table showing the join of Person and Book. I want to be able to sort the results by fields from both Person AND Book, and then get a List from Hibernate, and iterate ...

Getting fewer columns with hibernate

I have a table with 11 columns, but I need to get only 2 of them in my application, I'm using spring/hibernate/DAO combination. For now I have a domain class which includes all 11 fields, and mapping file which maps all 11 columns in table. How do I use get just 2 of them not all? ...