hibernate - could not execute statement; SQL [n/a] - saving nested object
Solution 1
I solved the problem by adding setting
@Column(name = "commission_fee_info", columnDefinition = "LONGVARBINARY")
as annotation for the field commisionFeeInfo
in the class Listing
Solution 2
For me,
@Column(columnDefinition="text")
solves my problem.
Comments
-
Paul over 3 years
I'm trying to save a nested object using hibernate and I receive
could not execute statement; SQL [n/a] Exception
CODE
@Entity @Table(name = "listing") @Inheritance(strategy = InheritanceType.JOINED) public class Listing implements Serializable { @Id @Column(name = "listing_id") private String listingId; @Column(name = "property_type") private PropertyType propertyType; @Column(name = "category") private Category category; @Column(name = "price_currency") private String priceCurrency; @Column(name = "price_value") private Double priceValue; @Column(name = "map_point") private MapPoint mapPoint; @Column(name = "commission_fee_info") private CommissionFeeInfo commissionFeeInfo; } public class MapPoint implements Serializable { private final float latitude; private final float longitude; } public class CommissionFeeInfo implements Serializable { private String agentFeeInfo; private CommissionFeeType commissionFeeType; private Double value; private Double commissionFee; } public enum CommissionFeeType implements Serializable { }
Using
RazorSQL
I saw thathibernate
definesMapPoint
andCommissionFee
asVARBINARY
What I can't understand, is the fact that hibernate manages to save it when commissionFeeInfo is not present. It has no problem with saving
MapPoint
Does anyone have an idea about what I do wrong?
UPDATE
I found out that if all attributes of
CommissionFeeInfo
exceptingagentFeeInfo
arenull
, the object will be saved without problems. If one of the other attributes is!= null
, the errors occur.UPDATE 2
I changed the type of all attributes of
CommissionFeeInfo
intoString
and the object will be saved without problem, but I can't let the attributes asString
.