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 that hibernate defines MapPoint and CommissionFee as VARBINARY
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 excepting agentFeeInfoare null, 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 into String and the object will be saved without problem, but I can't let the attributes as String.
I solved the problem by adding setting
@Column(name = "commission_fee_info", columnDefinition = "LONGVARBINARY")
as annotation for the field commisionFeeInfo in the class Listing
For me,
@Column(columnDefinition="text")
solves my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With