java - Hibernate @MapKeyColumn and table inheritance causing Unknown column type exception -


let me know I upgraded from Hibernate 4.2.5.Final 4.3.6.Final, 4.3.6 Hibernate Libs are creating a mysql unknown column type exception. The following sections have been simplified because I am unable to fully show the production codes of my companies. @Entity @ tables (name = "region") public square area {private integer ID; Private map & lt; BasicType, BasicConfiguration & gt; ConfigurationMap = New Hashmap & lt; BasicType, Basic Configuration & gt; (); @Id @ Generated Values ​​(strategy = generation typeIndi) Public Integer Mill ID () {Return ID; } Public Zero Set ID (Integer ID) {this.id = id; } @OneToMany (speed = FetchType.EAGER, cascade = {} CascadeType.ALL, orphanRemoval = true) @JoinTable (name = "area_configuration", joinColumns = {@JoinColumn (name = "area_id")}, inverseJoinColumns = {@JoinColumn (Name = "basic_configuration_id")}) @mamkeemannnet (EnumType.STRING) @MapKeyColumn (name = "type") public map & lt; BasicType, BasicConfiguration & gt; GetConfigurationsMap () {Return Configuration Map; }

While the original type is simply a NAM

  public enum Basic type {TYPE1, TYPE2, TYPE3, TYPE4, TYPE5; }   

and basic configuration:

  @Entity @Table (name = "basic_configuration") @Inheritance (strategy = InheritanceType.JOINED) @DiscriminatorColumn ( Name = "type", differentiator type = dispute type. Column) public abstract class basic structure {private integer ID; @Id @ Generated Values ​​(strategy = generation typeIndi) Public Integer Mill ID () {Return ID; } Public Zero Set ID (Integer ID) {this.id = id; }}   

I have a test that attempts to continue a field object on a mysql db which generates the following error:

  ** Reason by: com .mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column in 'Field List' 'Type' ** On Sun. Ref.GeneratedConstructorAccessor73.newInstance (unknown source) sun.reflect.DellegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java 45) java.lang.reflect.Constructor.newInstance (Constructor.javaitter26) com.mysql.jdbc.Util.handleNewInstance at (Util .java: 408) on com.mysql.jd   

generate hibernate code does is that it tries to default insert type value in the configuration table and area_configuration table:

  ** Hibernate: Enter into the basic structure (unit_version, type) value (?, TYPE1) ** Test Run: 9, failures: 0, Errors: 9, omitted: 0, time elapsed: 0.208 seconds & lt; & Lt; & Lt; Failure! - javax.preistence.PersistenceException: org.hibernate.exception.SQLGrammarException: statement on org.hibernate.ejb.AbstractEntityManagerImpl.convert (Abrektantiaitiaiantiaimajeepikjawao 0.387) could not be executed. Sun.reflect.Ge at org.hibernate.ejb.AbstractEntityManagerImpl.convert (AbstractEntityManagerImpl.java.1316) at org.hibernate.ejb.AbstractEntityManagerImpl.persist (AbstractEntityManagerImpl.java:881) at Hibernate.ejb.AbstractEntityManagerImpl.convert: 1310   

This error has been introduced in Hibernation in version 4.2.9. The above, 4.2.9 has been found in the following versions. It is not the problem at the root, nobody knows how can I solve it? thanks a lot.

I remember that there is a similar problem. See your code here:

  @Entity @Table (name = "basic_configuration") @Inheritance (strategy = InheritanceType.JOINED) @DiscriminatorColumn (name = "type", discriminatorType = DiscriminatorType.STRING ) Public abstract class basic structure {Private Integer ID; @Id @ Generated Values ​​(strategy = generation typeIndi) Public Integer Mill ID () {Return ID; } Public Zero Set ID (Integer ID) {this.id = id; }}   

In this line - & gt;

  @DiscriminatorColumn (name = "type", discriminatorType = DiscriminatorType.STRING)   

You are using a reserved word, "like" . Check this list:



Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -