This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate - Simple mapping to object  RSS feed

 
Craig Taylor
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently modified a field that had previously been mapped as an Enum String to a Class and am having problems finding the proper definition to inform Hibernate of the class.

The error I'm receiving is :


Whereas for enumerations I had a defintion similair to (using annotations):
;

I'm attempting to use something like :


I have ensured that I have a String constructor for the FieldObjectType class.

The only way I can possibly see of doing it is to write my own UserType - yet I feel like this should be a common case that may have a quicker solution.

Thanks,
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Embedded is the annotation that you use for mapping a component object, or a <component> tag in Hibernate XML mappings.
 
Craig Taylor
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, perfect - just what I needed.

I had gotten around it temporarily by creating my own proxied @Temporal fields that would create the object but this looks like a much better approach.

Thanks,
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!