David The Man
David The Man

Reputation: 259

Map a custom type to database column

Let's say I have a model class A who has a member of class B which is not a model. How can make it so that class A can be saved as an entity and class B transformed into something more pleasent for the database such as a string.

Upvotes: 1

Views: 214

Answers (2)

i.am.michiel
i.am.michiel

Reputation: 10404

I don't get it. You want to save an item but not use it as model? Plus, normally for non model/entity items, they are automatically transformed into binary format and saved.

If you really want "a more pleasant" format for the database, use an Model/Entity annotation.

Upvotes: 3

emt14
emt14

Reputation: 4896

Add to class A

String mystring = myB.toString();

then mystring will be persisted in your Model.

Upvotes: 0

Related Questions