[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3579) Support for PostgreSQL UUID data type

Batbayar Bazarragchaa (JIRA) noreply at atlassian.com
Fri Feb 20 02:31:38 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3579?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32461#action_32461 ] 

Batbayar Bazarragchaa commented on HHH-3579:
--------------------------------------------

You said create custom data type and map it to java.util.UUID.
Please help me to solve this.

My mapping file:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Feb 18, 2009 10:11:16 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
  <class name="persistence.MessageBuffer" schema="public" table="message_buffer">
    <id name="timestamp" type="timestamp">
      <column length="35" name="timestamp"/>
      <generator class="assigned"/>
    </id>
    <property name="message" type="string">
      <column name="message"/>
    </property>
    <property name="routingKey" type="string">
      <column name="routing_key"/>
    </property>
    <property name="ok" type="java.lang.Boolean">
      <column name="ok"/>
    </property>
    <property name="uuid" sql-type="uuid">
      <column name="uuid"/>
    </property>
    <property name="send" type="timestamp">
      <column length="35" name="send"/>
    </property>
  </class>
</hibernate-mapping>
[/code]

How would be my class file?
[code]
import java.io.Serializable;

public class PosgtreUUID implements Serializable {

}
[/code]

> Support for PostgreSQL UUID data type
> -------------------------------------
>
>                 Key: HHH-3579
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3579
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: core
>    Affects Versions: 3.3.1
>            Reporter: Olivier Van Acker
>
> PostgreSQL has since version 8.3 UUID as data type nativly supported in the database. 
> The only way to get this to work in Hibernate is to add <column name="id" sql-type="uuid"/> to your mappings file (or @columnDefinition via annotations)
> and create your own custom usertype (e.g. public class UUIDUserType implements UserType, Serializable {..} ) and map this to java.util.UUID 
> worth mentioning is that java.util.UUID is only introduced in java 1.5 so there might be a backwards compatibility problem
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list