From the official hibernate documentation:
@org.hibernate.annotations.Type overrides the default hibernate type used: this is generally not necessary since the type is correctly inferred by Hibernate
There is an example from the documentation:
@Type(type="org.hibernate.test.annotations.entity.MonetaryAmountUserType")
@Columns(columns = {
@Column(name="r_amount"),
@Column(name="r_currency")
})
public MonetaryAmount getAmount() {
return amount;
}
I don't understand that. We declare @Type(type="org.hibernate.test.annotations.entity.MonetaryAmountUserType")
but the method's return value has the type MonetaryAmount
.
I expected that the type declared within the type annotation and the type of the returned value should be the same type.
Couldn't someone explain the actual purposes of the type, declared within the @Type
annotation. Why is it differ from the returned type?