Search code examples
javahibernateinheritancesavetransient

java, MySQL and Unknown column 'DTYPE' in 'field list'


I have 2 classes: A and B such that B extends A. Using hibernate, A is a normal concrete Entity, with an associated table, and everything there is fine.

B is defined so that it extends A, and A and B are Serializable, and has 2 extra members for which I have the @Transient annotation. I do not want these to be saved in DB, and for all I care, to me all rows in that table are just instances of A, persisted. Target is to occasionally save B instances in the session. However at some point I need to save a B object in DB (as if it were an A). I do not have or need a DiscriminatorColumn or anything like that.

I have tried things like:

session.saveOrUpdate((A) b);

... with b an instance of B. This failed.

Anyone has an idea on how to solve this?


Solution

  • I would guess that you've added @Entity to your class B. This creates an entity class hierarchy - with the need to distinguish the different entity classes. If you remove the annotation, the column is not needed anymore.