I'm having a bit of an issue with hibernate validating during application deployment. I have two classes, Frame and FrameReleasePlan that are associated in a OneToOne relationship. On the database side, the relationship is unidirectional. The frame_release_planss table has a 'frame_id' column of type NUMERIC(19,0) that is a foreign key pointing to the 'id' column of the frames table. When I try to deploy, the schema validation fails with the error:
Unable to build Hibernate SessionFactory. Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [frame_id] in table [frame_release_plans]; found [numeric (Types#NUMERIC)], but expecting [bigint (Types#BIGINT)]"}
I have tried manually specifying the column type using the 'columnDefinition' argument of the @JoinColumn annotation, but it made no difference. Is there any way to fix this with having to change the database column to 'bigint'?
persistence.xml
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ProductPersistenceUnit"
transaction-type="JTA">
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2012Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.id.new_generator_mappings" value="false"/>
</properties>
</persistence-unit>
</persistence>
Code Snippets:
@Entity(name = "FrameReleasePlan")
@Table(name = "frame_release_plans")
@Audited
@Access(AccessType.FIELD)
public class FrameReleasePlan extends AbstractFrameReleasePlan
{
@OneToOne
@JoinColumn(name = "frame_id")
protected Frame frame;
}
@Entity(name = "Frame")
@DiscriminatorValue("FRAME")
public class Frame extends Product
{
@OneToOne(mappedBy = "frame", cascade = { CascadeType.ALL }, orphanRemoval = true)
protected FrameReleasePlan releasePlan;
}
@javax.persistence.Entity(name = "Product")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = "products")
public abstract class Product extends Entity
{
@Id
@DocumentId
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(columnDefinition = "NUMERIC(19,0)")
protected Long id;
}