0

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 Answers 2

2

You should map it as a component

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.