1

I'm wondering if it's possible to map different data types. For instance, I have a Visit data type in Java, which has a userEmail field which is of the type String, and can I map it with hibernate to a database table which would have userID instead of userEmail? And according to the id it would find the email and return to java the email and vice versa? Is this possible?

If yes, then how would the mapping look like? Or how is this supposed to look like:

<many-to-one name="patientEmail" 
    column="idPatient" 
    not-null="true" 
    class="com.my.myapp.datamodel.Patient"/>

1 Answer 1

2

Yes, you can.

You have to create one class which extend to UserType of Hibernate.

Custom UserType Hibernate

It can be user like :

@Column(name = "commission_type")
        @Type(type = "com.core.commission.model.FNEnumUserType", parameters = @Parameter(name = "type", value = "com.core.commission.dto.CommissionType"))
        private CommissionType commissionType;

Where FNEnumUserType is cstom data type same like you have Visit

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

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.