Posts

Showing posts from January, 2011

Hibernate Exceptions Errors and Causes

The following section will list the general exception that we get while dealing with hibernate. org.hibernate.ObjectDeletedException:deleted object would be re-saved by cascade when we try to delete the child object and don't remove the association, for instance we loaded a parent object with list of child and then we deleted one of the child object but did not removed the child from the parent. Example, Box gotBox =(Box)dao.load(Box.class, box.getBoxId()); List boxitem = new ArrayList(gotBox.getBoxItems()); BoxItem deleteItem = boxitem.get(0); dao.deletItem(deleteItem.getItemName()); Solution is, remove the transient instance from the parent object(Box) like.   gotBox.getBoxItems().remove(deleteItem); OR use   @Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN) on the child object. ------------------------------------------------------------------------------------------------- No Dialect mapping for JDBC type: -1 We get this ex

DB2 Specific Working Titbits

We can find if a table needs to be reorged or not by using the following query. db2 "select tabschema,tabname from SYSIBMADM.ADMINTABINFO where reorg_pending='Y'" To get the information about the Table and Schema from the TBSSPACEID and TableID use the following SQL. SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME FROM SYSCAT.TABLES AS T, SYSCAT.COLUMNS AS C WHERE T.TBSPACEID = 3 AND T.TABLEID = 258 AND C.COLNO = 6 AND C.TABSCHEMA = T.TABSCHEMA AND C.TABNAME = T.TABNAME Selecting or Generating the Next Value for a particular Sequence in DB2. For example say we have a sequece name PAYMENT_TABLE_SEQ,  and we want to check wheather this sequence is working or not we can do it by the following SQL in DB2, values(NEXTVAL FOR PAYMENT_TABLE_SEQ )  Using the above we can generate the next value for a particular Sequence and also make sure that the sequence is working

Effect of Select Strategies in Hibernate How and When

STUDY : Hibernate Common Issues and Tips Effect of Select Strategies in Hibernate (How and When) Hibernate is one of the most popular ORM tools. In my own experience I have found that in the application development life cycle we often get some common hibernate related issues, be it performance related issues or Exception generated by hibernate. I have tried to capture the exception or problems we get while  using hibernate in the data access layer. The overall finding is divided in to different scene's. In Hibernate 3 when we load a particular object from db, only that object is loaded and the associated objects are not loaded.  For example if we have a relationship like      Director   ---> Movies(many) If we now load the director all the movies will not be retrieved from data base . We can control this behavior like whether to load the related objects(movies in this case) using fetching strategies. By default all the related objects(in our case all the movie ob