/** * Returns the java type of the discriminator column. * * @param metadata * @return the java type of the discriminator column * @since 2.0.0 */ private static Class<?> getJavaType(DiscriminatorColumnMetadata metadata) { if (metadata == null) { return String.class; } switch (metadata.getDiscriminatorType()) { case STRING: return String.class; case INTEGER: return Integer.class; default: return char.class; } }
/** * @param jdbcAdaptor the JDBC adaptor * @param primaryTable the primary table * @param metadata the metadata * @since 2.0.0 */ public DiscriminatorColumn( JdbcAdaptor jdbcAdaptor, EntityTable primaryTable, DiscriminatorColumnMetadata metadata) { super( DiscriminatorColumn.getJavaType(metadata), null, null, null, false, metadata != null ? metadata.getLocator() : null); this.name = jdbcAdaptor.escape(metadata != null ? metadata.getName() : "DTYPE"); this.table = primaryTable; this.columnDefinition = metadata != null ? metadata.getColumnDefinition() : null; this.discriminatorType = metadata != null ? metadata.getDiscriminatorType() : DiscriminatorType.STRING; this.length = metadata != null ? (metadata.getDiscriminatorType() == DiscriminatorType.CHAR ? 1 : metadata.getLength()) : 31; this.table.addColumn(this); }