Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hibernate and XmlGregorianCalendar

Posted on 2011-03-11
7
Medium Priority
?
1,709 Views
Last Modified: 2013-11-13
Hi,

I'm using JAXB and also Hibernate. But, I got a problem with Hibernate and XmlGregorianCalendar.

Below is a part of my class witch works with JAXB.
...
public class test
{
    ...
    @XmlElement(name = "Created", required = true)
    protected XMLGregorianCalendar created;
    @XmlElement(name = "CreatedBy", required = true)
    protected String createdBy;
    @XmlElement(name = "Changed", required = true)
    protected XMLGregorianCalendar changed;
    @XmlElement(name = "ChangedBy", required = true)
    protected String changedBy;
    ...

Open in new window

The problem I got now is that I don't know what to do to get it to work with Hibernate and how to create a mapping file to this class when using XMLGregorianCalendar. If I change XMLGregorianCalendar to java.util.Date I get it to work with Hibernate but not with JAXB.

Is there any solution to this?

0
Comment
Question by:freeOne
  • 3
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 35107812
I'd suggest using different beans for jaxb and hibernate, specifying the mapping for both in one class gets messy.
And you can get your jaxb class automatically generated from your xml schema
0
 

Author Comment

by:freeOne
ID: 35107880
Which ones do you recomend?
0
 
LVL 92

Expert Comment

by:objects
ID: 35107942
I generally map the actual bean with hibernate
and generate a seperate bean (from the xsd) for exporting/importing from xml.
Then you just need a utility method to convert between the two when you need to go to/from xml
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:freeOne
ID: 35108077
Is it possible to get an example?
0
 

Author Comment

by:freeOne
ID: 35108117
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 35112963
> Is it somthing like this you meean?

yes, though we usually start with an xsd schema, and generate the classes directly from that
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/twbs_jaxbschema2java.html
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question