hibernate

using a Map to create primary keys using Hibernate Annotations.

I'm not too used to ORM mapping, having come from a PHP background. I'm trying to achieve a link between a series of questions and their possible answers, along with the correct answer from that set. I'm trying to create a Question object that can be queried for it's corresponding Answers, but unfortunately, the best Java classes I've c...

Hibernate callbacks

I want to tell hibernate to give me a callback notification when a new row is inserted into my database (this row is inserted by another system/application.) Im using mysql cluster and replicates the databases within the cluster. As soon as some of the databases is changed the other systems must be informed about this change. Is Hibern...

Transactional strategy for Hibernate L2 Cache

If Hibernate L2 cache vendor supports "transactional" strategy, then does it mean that this cache guarantees the same level of isolation between transactions as specified in Hibernate config? For example, if cache supports "read-write" strategy then it guarantees REPEATABLE_READ isolation level (and in some cases only READ_COMMITTED lev...

[HQL/Hibernate] Error: Cannot convert value '0000-00-00 00:00:00' from column 13 to TIMESTAMP

the field definition /** Date. */ @Column(columnDefinition = "datetime") private Date date; setter public void setDate(final Date date) { DateFormat dfmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { this.date = dfmt.parse(dfmt.format(date)); } catch (ParseException e) { // TODO Auto-generated catc...

Problem persisting a java.util.Date into MySql using Hibernate

I've been debugging this problem for the last couple of hours with no success and figured I'd throw it out to SO and see where that goes. I'm developing a Java program that persists data into a MySql database using Hibernate and the DAO/DTO pattern. In my database, I have a memberprofile table with a firstLoginDate column. In the databa...

Facet Version Must be 5.0 - Using Javassist in Websphere

I have a Websphere 6.1 EAR that I am trying to deploy and I am currently getting the following message when I add javassist-3.4.GA.jar to the EAR. Facet version for Enterprise Application project IntegrationEARProject must be 5.0 to contain Java EE 5.0 project lib //{path to file}/hibernate/R3_3_1/jars/javassist-3.4.GA.jar. Currently t...

How can I validate a field as required depending on another field's value in SEAM?

I'm trying to create a simple custom validator for my project, and I can't seem to find a way of getting seam to validate things conditionally. Here's what I've got: A helper/backing bean (that is NOT an entity) @RequiredIfSelected public class AdSiteHelper { private Date start; private Date end; private boolean selected; /* g...

how to do order-by in hibernate mapping

suppose Object A has a list of Object B, and Object B must have a object C, B can be order base on C.level . In A.hbm.xml <bag name="listB" table="T_B" inverse="false" order-by="?? what should i do here???" > <key column="ID_A" not-null="true"/> <many-to-many colum...

Return a column in hql select clause without actually using that column

I have a query which returns a list of objects like such: select distinct ref from references where [...] I'd like to order these by a field not on ref but on an association of ref, i.e.: select distinct ref from references where [...] order by ref.foo.name Unfortunately this doesn't work in Oracle (once the query is translated to ...

Hql problem in where clause

I have a persistent class Author with two fields: int id, String name. Problem is that whenever I execute query this way: Session s = HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction(); Query q = s.createQuery("from Author"); return (Author)q.list().get(0); It works fine and returns me an Author object with ...

Why do we use hibernate annotation?

Why is it important? what are advantage according to XML mapping? Can you explan these? thank you. ...

hibernate mapping

Is hibernate mapping necessary a lot? Which mapping is important for project? one-to-one, many-to-one, many-to-many?? ...

Grails and Hibernate's Lazy Initialization Exception

Where are the most common places where you've gotten an org.hibernate.LazyInitializationException in Grails, what was the cause and how did you solve it ? I think this one exception comes up a lot for novice, so if you'd provide more examples, it would be great. ...

Single column in JSF DataTable displaying wrong data

We are using JSF, Seam, and Hibernate. I am debugging a view that has a JSF Datatable that is getting its data from an EntityQuery. The EntityQuery has only the method getEjbql defined and is returning a query like "select viewA from ViewA viewA". The JSF DataTable is displaying the data correctly except for one column which is displayin...

Need easy way to force all DynaBean property names to lower case

I'm developing functionality that can operate on concrete data beans returned via Hibernate, or DynaBeans returned by using Jakarta Commons/BeanUtils' RowSetDynaClass (which wraps a JDBC result set). RowSetDynaClass by default forces all bean property names to lower case, and I need to convert all my concrete beans from Hibernate to Dyn...

Updating built in Spring/Hibernate Archetype in Maven?

The current version of Hibernate is 3.26 and Spring is 2.54 when I create a Spring and Hibernate project based off the default Archetype. How can I have Maven grab the newest release versions? I tried changing my spring version from 2.5.4 to 2.5.6 but 2.5.4 was still included in the generated war file. ...

How do we count rows using Hibernate?

For example, if we have a table Books, how would we count total number of book records with hibernate? Thanks ...

Hibernate mapping inheritance

I have a class ClassA mapped to TableA. I also have a mapping for it and it has an entity-name of EntityA. Now, I need to create another mapping named EntityATwo between ClassA for TableA, but slightly different. Although I could copy-paste the mapping of EntityA to EntityATwo, it would be very difficult to maintain that. Thus, my q...

Hibernate Groovy entities

Hi All! I'm have a groovy hibernate entity, named 'Depart' for example. Now when i'm try to get their property (for example Long id = somedepart.getIdDepart() ) i'm got an exception Cannot cast Depart to Depart_$$_javassist_5 Who make Depart_$$_javassist_5 - groovy or hibernate? Is there some workaround about this? ...

How do you programmatically turn off eager fetching with hibernate?

I have in my mapping an association to an eagerly loaded collection (lazy="false" fetch="subselect"). How can I turn that off programmatically with Hibernate when I do a query? Thanks ...