如何修复JPA中的'ERROR SqlExceptionHelper列'cardinalidadid'未找到'错误

时间:2019-08-20 08:00:30

标签: sql jpa entity

我想映射一个实体,该实体与另一个表有关系,但是当映射该关系时,它找不到“基数”列。

这是代码:

实体元素:

@Entity
@Table(name = "elemento")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="clave", discriminatorType = DiscriminatorType.STRING, length=10)

public class Elemento implements Serializable, GenericInterface {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id")
private Integer id;

@Column(name = "clave", insertable = false)
private String clave;

@Column(name = "numero")
private String numero;

@Column(name = "nombre")
private String nombre;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Proyectoid")
private Proyecto proyecto;

@Column(name = "descripcion")
private String descripcion;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "EstadoElementoid", referencedColumnName="id")
private EstadoElemento estadoElemento;

实体演员:

@Entity
@Table(name = "actor")
@Inheritance(strategy=InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name = "Elementoid", referencedColumnName = "id")
@DiscriminatorValue("ACT")

public class Actor extends Elemento implements Serializable, GenericInterface, ElementoInterface {

private static final long serialVersionUID = 1L;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "Cardinalidadid", referencedColumnName = "id")
private Cardinalidad cardinalidad;

这是表格的描述:

餐桌演员:

    | actor | CREATE TABLE `actor` (
    `otraCardinalidad` varchar(45) DEFAULT NULL,
    `Elementoid` int(11) NOT NULL,
    `Cardinalidadid` int(11) NOT NULL,
     PRIMARY KEY (`Elementoid`),
     KEY `FKActor872913` (`Cardinalidadid`),
     KEY `FKActor148309` (`Elementoid`),
     CONSTRAINT `FKActor148309` FOREIGN KEY (`Elementoid`) REFERENCES 
     `elemento` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
     CONSTRAINT `FKActor872913` FOREIGN KEY (`Cardinalidadid`) REFERENCES 
     `cardinalidad` (`id`) ON UPDATE CASCADE
     ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

TABLE CARDINALIDAD

     | cardinalidad | CREATE TABLE `cardinalidad` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `nombre` varchar(10) NOT NULL,
     PRIMARY KEY (`id`),
     UNIQUE KEY `uniqueCardinalidad` (`nombre`)
     ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 |

出现此错误

    02:57:43.663 [qtp1469821799-35] DEBUG 
    com.mchange.v2.c3p0.impl.NewPooledConnection - 
    com.mchange.v2.c3p0.impl.NewPooledConnection@48c2c8ce handling a 
    throwable. java.sql.SQLException: Column 'cardinalidadid' not found.

0 个答案:

没有答案