mysql - Entity inheritance an error while refreshing with EntityManager -
when using entity inheritance hierarchy witch @discriminatorcolumn storing discriminatortype.string values in mysql enum. below code example:
@entity @discriminatorcolumn(name ="account_type", discriminatortype = discriminatortype.string, columndefinition = "enum('natural_person', 'firm', 'provider', 'employee', 'administrator', 'moderator', 'user')") @discriminatorvalue("user") public class user implements serializable { ... }
and inherited entity:
@entity @discriminatorvalue("firm") public class firm extends user { ... }
when create firm object or removes works ok, when find entitymanager, if make enitymanager.refresh(firm) there error complaining about:
caused by: com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: unknown column 'firm0_.account_type' in 'field list'
update:
when changed columndefinition of @descriminatorcolumn deleting , storing strings "firm", "user", error occures!
update 2:
i have little suggestion firm extends useraccount discriminator column account_type should in user_account table. error firm0.account_type seems stupid search column in user_account.account_type! have subclass person , persists , saves ok, firm persists, removes don't refresh!
update 3:
found sql log this:
hibernate: insert user_account (activation_code, email, last_failed_login, last_logged, login, password, registration_date, account_type) values (?, ?, ?, ?, ?, ?, ?, 'firm') hibernate: insert firm (address_city, address_country, address_office_no, address_building_no, address_state, address_street, address_zip_code, client_id, company_number, name, phone_number, skype_name, statistic_number, vatin, user_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) hibernate: select firm0_.user_id user_id2_14_0_, firm0_1_.activation_code activati3_14_0_, firm0_1_.email email4_14_0_, firm0_1_.last_failed_login last_fai5_14_0_, firm0_1_.last_logged last_log6_14_0_, firm0_1_.login login7_14_0_, firm0_1_.password password8_14_0_, firm0_1_.registration_date registra9_14_0_, firm0_.address_city address_1_3_0_, firm0_.address_country address_2_3_0_, firm0_.address_office_no address_3_3_0_, firm0_.address_building_no address_4_3_0_, firm0_.address_state address_5_3_0_, firm0_.address_zip_code address_7_3_0_, firm0_.client_id client_15_3_0_, firm0_.company_number company_8_3_0_, firm0_.name name9_3_0_, firm0_.skype_name skype_n11_3_0_, firm0_.statistic_number statist12_3_0_, firm0_.vatin vatin13_3_0_, firm0_2_.corporation_id corporat5_8_0_, firm0_2_.description descript1_8_0_, firm0_2_.name name2_8_0_, firm0_2_.type type3_8_0_, firm0_.account_type account_1_14_0_ firm firm0_ inner join user_account firm0_1_ on firm0_.user_id=firm0_1_.user_id left outer join provider firm0_2_ on firm0_.user_id=firm0_2_.provider_id firm0_.user_id=? jun 10, 2015 5:37:16 pm org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions warn: sql error: 1054, sqlstate: 42s22 jun 10, 2015 5:37:16 pm org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions error: unknown column 'firm0_.account_type' in 'field list' jun 10, 2015 5:37:16 pm org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl stop info: hhh000030: cleaning connection pool
i'm guessing when jpa generates ddl using columndefinition string literal column definition. thus, should "account_type enum('natural_person', 'firm', 'provider', 'employee', 'administrator', 'moderator', 'user')"
Comments
Post a Comment