We're updating the issue view to help you get more done. 

Envers - ERROR: Field 'DTYPE' doesn't have a default value

Description

There is a big issue when envers is updating data on inherited classes.The problem is that AUD table attached to SystemUser class is not putting the DTYPE value as you can see below inside the SQL queries - the AUD table for SystemUSer has DTYPE column which is not null so event if my base file is inserted corretly into db the porblem is thaht the update of audit table for system user cause transaction rollback.
So DTYPE should be null on audit tables or it should be fixed to put the dtype value when updating the systemuser

My classes:

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Audited
@DiscriminatorValue(value = "SystemUser")
public class SystemUser

@Audited
@DiscriminatorValue(value = "Employee")
public class Employee extends SystemUser implements Serializable

@Table(name = "base_file")
@Audited
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class BaseFile

@Audited
@DiscriminatorValue(value = "InspectionFile")
public class InspectionFile extends BaseFile implements Serializable {

@JoinColumn(name = "inspection", referencedColumnName = "id")
@ManyToOne(optional = true, cascade = CascadeType.ALL)
private Inspection inspection;

}

INFO: Hibernate: select inspection0_.id as id1_25_9_, inspection0_1_.briefcase as briefcas8_25_9_, inspection0_1_.create_timestap as create2_25_9_, inspection0_1_.document_notification_template as document9_25_9_, inspection0_1_.document_type as documen10_25_9_, inspection0_1_.modification_timestamp as modifica3_25_9_, inspection0_1_.name as name4_25_9_, inspection0_1_.password as password5_25_9_, inspection0_1_.password_required as password6_25_9_, inspection0_1_.version as version7_25_9_, inspection0_.completion_term as completi1_39_9_, inspection0_.description as descript2_39_9_, inspection0_.equipment as equipmen6_39_9_, inspection0_.notify as notify7_39_9_, inspection0_.planned_term as planned3_39_9_, inspection0_.type as type4_39_9_, briefcase1_.id as id1_7_0_, briefcase1_.name as name2_7_0_, documentno2_.id as id1_49_1_, documentty3_.id as id1_31_2_, documentty3_.document_type_notification_template as document3_31_2_, documentty3_.name as name2_31_2_, documentty4_.id as id1_49_3_, usersacces5_.document_type as document3_31_11_, usersacces5_.id as id1_33_11_, usersacces5_.id as id1_33_4_, usersacces5_.document_type as document3_33_4_, usersacces5_.granted as granted2_33_4_, usersacces5_.system_user as system4_33_4_, equipment6_.id as id1_37_5_, equipment6_.description as descript2_37_5_, equipment6_.manufacture_date as manufact3_37_5_, equipment6_.name as name4_37_5_, equipment6_.number_in as number5_37_5_, equipment6_.number_out as number6_37_5_, equipment6_.purchase_date as purchase7_37_5_, systemuser7_.id as id1_64_6_, systemuser7_.is_admin as is2_64_6_, systemuser7_.city as city3_64_6_, systemuser7_.company as company19_64_6_, systemuser7_.create_timestamp as create4_64_6_, systemuser7_.email as email5_64_6_, systemuser7_.first_name as first6_64_6_, systemuser7_.last_failure_login as last7_64_6_, systemuser7_.last_login as last8_64_6_, systemuser7_.last_name as last9_64_6_, systemuser7_.login as login10_64_6_, systemuser7_.password as passwor11_64_6_, systemuser7_.phone as phone12_64_6_, systemuser7_.registration_code as registr13_64_6_, systemuser7_.registration_confirmed as registr14_64_6_, systemuser7_.street as street15_64_6_, systemuser7_.streetNumber as streetN16_64_6_, systemuser7_.is_superuser as is17_64_6_, systemuser7_.system_user_role as system20_64_6_, systemuser7_.zip as zip18_64_6_, company8_.id as id1_11_7_, company8_.city as city2_11_7_, company8_.name as name3_11_7_, company8_.nip as nip4_11_7_, company8_.regon as regon5_11_7_, company8_.street as street6_11_7_, company8_.street_number as street7_11_7_, company8_.zip as zip8_11_7_, systemuser9_.id as id1_66_8_, systemuser9_.role_id as role2_66_8_ from inspection inspection0_ inner join document inspection0_1_ on inspection0_.id=inspection0_1_.id left outer join briefcase briefcase1_ on inspection0_1_.briefcase=briefcase1_.id left outer join document_notification_template documentno2_ on inspection0_1_.document_notification_template=documentno2_.id left outer join notification_template documentno2_1_ on documentno2_.id=documentno2_1_.id left outer join document_type documentty3_ on inspection0_1_.document_type=documentty3_.id left outer join document_type_notification_template documentty4_ on documentty3_.document_type_notification_template=documentty4_.id left outer join notification_template documentty4_1_ on documentty4_.id=documentty4_1_.id left outer join document_type_access usersacces5_ on documentty3_.id=usersacces5_.document_type left outer join equipment equipment6_ on inspection0_.equipment=equipment6_.id left outer join system_user systemuser7_ on inspection0_.notify=systemuser7_.id left outer join company company8_ on systemuser7_.company=company8_.id left outer join system_user_role systemuser9_ on systemuser7_.system_user_role=systemuser9_.id where inspection0_.id=?
INFO: Hibernate: select role0_.id as id1_58_1_, role0_.name as name2_58_1_, roleaccess1_.role as role4_58_3_, roleaccess1_.id as id1_60_3_, roleaccess1_.id as id1_60_0_, roleaccess1_.access_view as access2_60_0_, roleaccess1_.granted as granted3_60_0_, roleaccess1_.role as role4_60_0_ from role role0_ left outer join role_access_view roleaccess1_ on role0_.id=roleaccess1_.role where role0_.id=?
INFO: Hibernate: select systemuser0_.id as id1_64_3_, systemuser0_.is_admin as is2_64_3_, systemuser0_.city as city3_64_3_, systemuser0_.company as company19_64_3_, systemuser0_.create_timestamp as create4_64_3_, systemuser0_.email as email5_64_3_, systemuser0_.first_name as first6_64_3_, systemuser0_.last_failure_login as last7_64_3_, systemuser0_.last_login as last8_64_3_, systemuser0_.last_name as last9_64_3_, systemuser0_.login as login10_64_3_, systemuser0_.password as passwor11_64_3_, systemuser0_.phone as phone12_64_3_, systemuser0_.registration_code as registr13_64_3_, systemuser0_.registration_confirmed as registr14_64_3_, systemuser0_.street as street15_64_3_, systemuser0_.streetNumber as streetN16_64_3_, systemuser0_.is_superuser as is17_64_3_, systemuser0_.system_user_role as system20_64_3_, systemuser0_.zip as zip18_64_3_, company1_.id as id1_11_0_, company1_.city as city2_11_0_, company1_.name as name3_11_0_, company1_.nip as nip4_11_0_, company1_.regon as regon5_11_0_, company1_.street as street6_11_0_, company1_.street_number as street7_11_0_, company1_.zip as zip8_11_0_, systemuser2_.id as id1_66_1_, systemuser2_.role_id as role2_66_1_, role3_.id as id1_58_2_, role3_.name as name2_58_2_ from system_user systemuser0_ left outer join company company1_ on systemuser0_.company=company1_.id left outer join system_user_role systemuser2_ on systemuser0_.system_user_role=systemuser2_.id left outer join role role3_ on systemuser2_.role_id=role3_.id where systemuser0_.system_user_role=?
INFO: Hibernate: select inspection0_.equipment as equipmen6_37_8_, inspection0_.id as id5_39_8_, inspection0_.id as id1_25_7_, inspection0_1_.briefcase as briefcas8_25_7_, inspection0_1_.create_timestap as create2_25_7_, inspection0_1_.document_notification_template as document9_25_7_, inspection0_1_.document_type as documen10_25_7_, inspection0_1_.modification_timestamp as modifica3_25_7_, inspection0_1_.name as name4_25_7_, inspection0_1_.password as password5_25_7_, inspection0_1_.password_required as password6_25_7_, inspection0_1_.version as version7_25_7_, inspection0_.completion_term as completi1_39_7_, inspection0_.description as descript2_39_7_, inspection0_.equipment as equipmen6_39_7_, inspection0_.notify as notify7_39_7_, inspection0_.planned_term as planned3_39_7_, inspection0_.type as type4_39_7_, briefcase1_.id as id1_7_0_, briefcase1_.name as name2_7_0_, documentno2_.id as id1_49_1_, documentty3_.id as id1_31_2_, documentty3_.document_type_notification_template as document3_31_2_, documentty3_.name as name2_31_2_, documentty4_.id as id1_49_3_, systemuser5_.id as id1_64_4_, systemuser5_.is_admin as is2_64_4_, systemuser5_.city as city3_64_4_, systemuser5_.company as company19_64_4_, systemuser5_.create_timestamp as create4_64_4_, systemuser5_.email as email5_64_4_, systemuser5_.first_name as first6_64_4_, systemuser5_.last_failure_login as last7_64_4_, systemuser5_.last_login as last8_64_4_, systemuser5_.last_name as last9_64_4_, systemuser5_.login as login10_64_4_, systemuser5_.password as passwor11_64_4_, systemuser5_.phone as phone12_64_4_, systemuser5_.registration_code as registr13_64_4_, systemuser5_.registration_confirmed as registr14_64_4_, systemuser5_.street as street15_64_4_, systemuser5_.streetNumber as streetN16_64_4_, systemuser5_.is_superuser as is17_64_4_, systemuser5_.system_user_role as system20_64_4_, systemuser5_.zip as zip18_64_4_, company6_.id as id1_11_5_, company6_.city as city2_11_5_, company6_.name as name3_11_5_, company6_.nip as nip4_11_5_, company6_.regon as regon5_11_5_, company6_.street as street6_11_5_, company6_.street_number as street7_11_5_, company6_.zip as zip8_11_5_, systemuser7_.id as id1_66_6_, systemuser7_.role_id as role2_66_6_ from inspection inspection0_ inner join document inspection0_1_ on inspection0_.id=inspection0_1_.id left outer join briefcase briefcase1_ on inspection0_1_.briefcase=briefcase1_.id left outer join document_notification_template documentno2_ on inspection0_1_.document_notification_template=documentno2_.id left outer join notification_template documentno2_1_ on documentno2_.id=documentno2_1_.id left outer join document_type documentty3_ on inspection0_1_.document_type=documentty3_.id left outer join document_type_notification_template documentty4_ on documentty3_.document_type_notification_template=documentty4_.id left outer join notification_template documentty4_1_ on documentty4_.id=documentty4_1_.id left outer join system_user systemuser5_ on inspection0_.notify=systemuser5_.id left outer join company company6_ on systemuser5_.company=company6_.id left outer join system_user_role systemuser7_ on systemuser5_.system_user_role=systemuser7_.id where inspection0_.equipment=?
INFO: Hibernate: select systemuser0_.id as id1_64_3_, systemuser0_.is_admin as is2_64_3_, systemuser0_.city as city3_64_3_, systemuser0_.company as company19_64_3_, systemuser0_.create_timestamp as create4_64_3_, systemuser0_.email as email5_64_3_, systemuser0_.first_name as first6_64_3_, systemuser0_.last_failure_login as last7_64_3_, systemuser0_.last_login as last8_64_3_, systemuser0_.last_name as last9_64_3_, systemuser0_.login as login10_64_3_, systemuser0_.password as passwor11_64_3_, systemuser0_.phone as phone12_64_3_, systemuser0_.registration_code as registr13_64_3_, systemuser0_.registration_confirmed as registr14_64_3_, systemuser0_.street as street15_64_3_, systemuser0_.streetNumber as streetN16_64_3_, systemuser0_.is_superuser as is17_64_3_, systemuser0_.system_user_role as system20_64_3_, systemuser0_.zip as zip18_64_3_, company1_.id as id1_11_0_, company1_.city as city2_11_0_, company1_.name as name3_11_0_, company1_.nip as nip4_11_0_, company1_.regon as regon5_11_0_, company1_.street as street6_11_0_, company1_.street_number as street7_11_0_, company1_.zip as zip8_11_0_, systemuser2_.id as id1_66_1_, systemuser2_.role_id as role2_66_1_, role3_.id as id1_58_2_, role3_.name as name2_58_2_ from system_user systemuser0_ left outer join company company1_ on systemuser0_.company=company1_.id left outer join system_user_role systemuser2_ on systemuser0_.system_user_role=systemuser2_.id left outer join role role3_ on systemuser2_.role_id=role3_.id where systemuser0_.id=?
INFO: Hibernate: select documentfi0_.base_file as base11_25_11_, documentfi0_.id as id2_3_11_, documentfi0_.id as id2_3_10_, documentfi0_.create_timestap as create3_3_10_, documentfi0_.system_user as system8_3_10_, documentfi0_.filePath as filePath4_3_10_, documentfi0_.file_size as file5_3_10_, documentfi0_.name as name6_3_10_, documentfi0_.version as version7_3_10_, documentfi0_.document_base as document9_3_10_, documentfi0_.inspection as inspect10_3_10_, documentfi0_.DTYPE as DTYPE1_3_10_, systemuser1_.id as id1_64_0_, systemuser1_.is_admin as is2_64_0_, systemuser1_.city as city3_64_0_, systemuser1_.company as company19_64_0_, systemuser1_.create_timestamp as create4_64_0_, systemuser1_.email as email5_64_0_, systemuser1_.first_name as first6_64_0_, systemuser1_.last_failure_login as last7_64_0_, systemuser1_.last_login as last8_64_0_, systemuser1_.last_name as last9_64_0_, systemuser1_.login as login10_64_0_, systemuser1_.password as passwor11_64_0_, systemuser1_.phone as phone12_64_0_, systemuser1_.registration_code as registr13_64_0_, systemuser1_.registration_confirmed as registr14_64_0_, systemuser1_.street as street15_64_0_, systemuser1_.streetNumber as streetN16_64_0_, systemuser1_.is_superuser as is17_64_0_, systemuser1_.system_user_role as system20_64_0_, systemuser1_.zip as zip18_64_0_, company2_.id as id1_11_1_, company2_.city as city2_11_1_, company2_.name as name3_11_1_, company2_.nip as nip4_11_1_, company2_.regon as regon5_11_1_, company2_.street as street6_11_1_, company2_.street_number as street7_11_1_, company2_.zip as zip8_11_1_, systemuser3_.id as id1_66_2_, systemuser3_.role_id as role2_66_2_, document4_.id as id1_25_3_, document4_.briefcase as briefcas8_25_3_, document4_.create_timestap as create2_25_3_, document4_.document_notification_template as document9_25_3_, document4_.document_type as documen10_25_3_, document4_.modification_timestamp as modifica3_25_3_, document4_.name as name4_25_3_, document4_.password as password5_25_3_, document4_.password_required as password6_25_3_, document4_.version as version7_25_3_, document4_1_.completion_term as completi1_39_3_, document4_1_.description as descript2_39_3_, document4_1_.equipment as equipmen6_39_3_, document4_1_.notify as notify7_39_3_, document4_1_.planned_term as planned3_39_3_, document4_1_.type as type4_39_3_, document4_2_.approved as approved1_27_3_, document4_2_.confirmation_date as confirma2_27_3_, document4_2_.draw_date as draw3_27_3_, document4_2_.invoice_amount as invoice4_27_3_, document4_2_.note as note5_27_3_, document4_2_.office_number as office6_27_3_, case when document4_1_.id is not null then 1 when document4_2_.id is not null then 2 when document4_.id is not null then 0 end as clazz_3_, briefcase5_.id as id1_7_4_, briefcase5_.name as name2_7_4_, documentno6_.id as id1_49_5_, documentty7_.id as id1_31_6_, documentty7_.document_type_notification_template as document3_31_6_, documentty7_.name as name2_31_6_, equipment8_.id as id1_37_7_, equipment8_.description as descript2_37_7_, equipment8_.manufacture_date as manufact3_37_7_, equipment8_.name as name4_37_7_, equipment8_.number_in as number5_37_7_, equipment8_.number_out as number6_37_7_, equipment8_.purchase_date as purchase7_37_7_, systemuser9_.id as id1_64_8_, systemuser9_.is_admin as is2_64_8_, systemuser9_.city as city3_64_8_, systemuser9_.company as company19_64_8_, systemuser9_.create_timestamp as create4_64_8_, systemuser9_.email as email5_64_8_, systemuser9_.first_name as first6_64_8_, systemuser9_.last_failure_login as last7_64_8_, systemuser9_.last_login as last8_64_8_, systemuser9_.last_name as last9_64_8_, systemuser9_.login as login10_64_8_, systemuser9_.password as passwor11_64_8_, systemuser9_.phone as phone12_64_8_, systemuser9_.registration_code as registr13_64_8_, systemuser9_.registration_confirmed as registr14_64_8_, systemuser9_.street as street15_64_8_, systemuser9_.streetNumber as streetN16_64_8_, systemuser9_.is_superuser as is17_64_8_, systemuser9_.system_user_role as system20_64_8_, systemuser9_.zip as zip18_64_8_, inspection10_.id as id1_25_9_, inspection10_1_.briefcase as briefcas8_25_9_, inspection10_1_.create_timestap as create2_25_9_, inspection10_1_.document_notification_template as document9_25_9_, inspection10_1_.document_type as documen10_25_9_, inspection10_1_.modification_timestamp as modifica3_25_9_, inspection10_1_.name as name4_25_9_, inspection10_1_.password as password5_25_9_, inspection10_1_.password_required as password6_25_9_, inspection10_1_.version as version7_25_9_, inspection10_.completion_term as completi1_39_9_, inspection10_.description as descript2_39_9_, inspection10_.equipment as equipmen6_39_9_, inspection10_.notify as notify7_39_9_, inspection10_.planned_term as planned3_39_9_, inspection10_.type as type4_39_9_ from base_file documentfi0_ inner join system_user systemuser1_ on documentfi0_.system_user=systemuser1_.id left outer join company company2_ on systemuser1_.company=company2_.id left outer join system_user_role systemuser3_ on systemuser1_.system_user_role=systemuser3_.id left outer join document document4_ on documentfi0_.document_base=document4_.id left outer join inspection document4_1_ on document4_.id=document4_1_.id left outer join document_invoice document4_2_ on document4_.id=document4_2_.id left outer join briefcase briefcase5_ on document4_.briefcase=briefcase5_.id left outer join document_notification_template documentno6_ on document4_.document_notification_template=documentno6_.id left outer join notification_template documentno6_1_ on documentno6_.id=documentno6_1_.id left outer join document_type documentty7_ on document4_.document_type=documentty7_.id left outer join equipment equipment8_ on document4_1_.equipment=equipment8_.id left outer join system_user systemuser9_ on document4_1_.notify=systemuser9_.id left outer join inspection inspection10_ on documentfi0_.inspection=inspection10_.id left outer join document inspection10_1_ on inspection10_.id=inspection10_1_.id where documentfi0_.base_file=?
INFO: Hibernate: insert into base_file (create_timestap, system_user, filePath, file_size, name, version, inspection, DTYPE) values (?, ?, ?, ?, ?, ?, ?, 'InspectionFile')
INFO: Hibernate: update system_user set is_admin=?, city=?, company=?, create_timestamp=?, email=?, first_name=?, last_failure_login=?, last_login=?, last_name=?, login=?, password=?, phone=?, registration_code=?, registration_confirmed=?, street=?, streetNumber=?, is_superuser=?, system_user_role=?, zip=? where id=?
INFO: Hibernate: insert into revisions (first_name, last_name, login, remote_ip, revisionTimestamp, user_id) values (?, ?, ?, ?, ?, ?)
INFO: Hibernate: insert into base_file_AUD (REVTYPE, create_timestap, filePath, file_size, name, version, system_user, inspection, DTYPE, id, REV) values (?, ?, ?, ?, ?, ?, ?, ?, 'InspectionFile', ?, ?)
INFO: Hibernate: insert into system_user_AUD (REVTYPE, is_admin, city, create_timestamp, email, first_name, last_failure_login, last_login, last_name, login, password, phone, registration_code, registration_confirmed, street, streetNumber, is_superuser, zip, company, system_user_role, id, REV) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

Environment

Ubuntu 12.04, MySQL 5.5, JPA 2.0

Status

Assignee

Unassigned

Reporter

Tomasz Bożek

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.2.0.Final

Priority

Critical