Hi,
We have a requirement to use SQL Server with uniqueidentifiers as the UUID
primary key
If anyone else has a similar requirement then this is the post for you!
In order to get things working we have had to choose a specific primary key
generation strategy with Hibernate annotations which I am flagging here for
reference purposes
We were getting an error…
javax.servlet.ServletException: org.hibernate.AssertionFailure: null
identifier
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at
com.idna.admin.webapp.filter.StaticFilter.doFilterInternal(StaticFilter.java:106)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
…etc
Then I discovered this post from the Hibernate forum....
http://opensource.atlassian.com/projects/hibernate/browse/HB-658
>From this came the following class that was released in Hibernate v.3 to
deal with the issue mentioned above
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/id/GUIDGenerator.html
The source for this code is here:
http://opensource.atlassian.com/projects/hibernate/secure/attachment/10539/SQLServerGUIDGenerator.java
Solution For AppFuse User class:
Define a generic generator
@GenericGenerator
(
name="hibernate-uuid",
strategy="guid"
)
And apply it to the Id mapping
@Id
@GeneratedValue
(
generator="hibernate-uuid"
)
Reference:
Page 170, Chapter 4 Mapping persistent classes, Java persistence with
Hibernate
Kind Regards,
Matthew
--
View this message in context:
http://www.nabble.com/SQL-Server-with-UUID-tp19410041s2369p19410041.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]