SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot Mr. Ram's Avatar
    Join Date
    Nov 2005
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Thumbs up Hibernate configuration issue with DB2Dialect

    Our application is throwing the following error due to some incompatible issues with DB2Dialect.

    2011-11-29 11:03:10,638 ERROR java.lang.UnsupportedOperationException: dialect does not support GUIDs
    at org.hibernate.dialect.Dialect.getSelectGUIDString(Dialect.java:754)
    at org.hibernate.id.GUIDGenerator.generate(GUIDGenerator.java:50)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
    The issue seems to be related to the following entry in hibernate xml files.
    Code:
    <generator class="guid" />
    *) We would like to know the common <generator> element which is compatible with ORACLE and DB2, etc.
    *) We would like to know how to separate the hbm configurations based on database (ORACLE, DB2, MYSQL, etc.).

  2. #2
    SitePoint Zealot Mr. Ram's Avatar
    Join Date
    Nov 2005
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    We have fixed the issue by making customized class as follows.

    import org.hibernate.dialect.DB2Dialect;

    public class MyDB2Dialect extends DB2Dialect
    {

    public String getSelectGUIDString()
    {

    return "select GENERATE_UNIQUE() from DUAL";
    }
    }


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •