views:

232

answers:

2

Suppose I have an object like

public class Handle {
    private String handle;
    public Handle(String name) {
        this.handle=name;
    }
    public String toString() {
      return this.handle;
    }
 }

that is a property of some POJO that I would like to persist with Hibernate. How do I define the mapping for my POJO such that its Handle object is just stored as a string?

Clarification: What I was really asking here is, how do I persist custom types? The answer is to implement a UserType.

+2  A: 

You should map it as a component

Maurice Perry
A: 

I may have been unclear, but the basic solution to the question I was asking was to implement a Hibernate UserType.

Jake