HHH-18347 Fix cast type name using dialect's default size strategy
Also tests failing on MariaDB by avoiding `id` keyword as column name
This commit is contained in:
parent
cbe2f6ff89
commit
04ab85f155
|
@ -114,13 +114,15 @@ public class DdlTypeImpl implements DdlType {
|
|||
}
|
||||
else {
|
||||
//use the given length/precision/scale
|
||||
if ( precision != null && scale == null ) {
|
||||
final Size size = dialect.getSizeStrategy()
|
||||
.resolveSize( jdbcType, javaType, precision, scale, length );
|
||||
if ( size.getPrecision() != null && size.getScale() == null ) {
|
||||
//needed for cast(x as BigInteger(p))
|
||||
scale = javaType.getDefaultSqlScale( dialect, jdbcType );
|
||||
size.setScale( javaType.getDefaultSqlScale( dialect, jdbcType ) );
|
||||
}
|
||||
return castTypeNamePattern == null
|
||||
? getTypeName( length, precision, scale )
|
||||
: replace( castTypeNamePattern, length, precision, scale );
|
||||
? getTypeName( size.getLength(), size.getPrecision(), size.getScale() )
|
||||
: replace( castTypeNamePattern, size.getLength(), size.getPrecision(), size.getScale() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<hibernate-mapping>
|
||||
|
||||
<class name="org.hibernate.orm.test.mapping.fetch.subselect.Name" table="T_Name">
|
||||
<id name="id" column="id"/>
|
||||
<id name="id" column="c_id"/>
|
||||
<property name="name" column="c_name"/>
|
||||
|
||||
<property name="nameLength" formula="(select length(c_name) from T_Name where id = T_Name.id)"/>
|
||||
<property name="nameLength" formula="(select length(sub.c_name) from T_Name sub where c_id = sub.c_id)"/>
|
||||
|
||||
<bag name="values" inverse="true" lazy="false" fetch="subselect">
|
||||
<key column="name_id"/>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
package="org.hibernate.orm.test.bidi">
|
||||
|
||||
<class name="Auction" table="TAuction">
|
||||
<id name="id">
|
||||
<id name="id" column="c_id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="description"/>
|
||||
|
@ -25,13 +25,13 @@
|
|||
</bag>
|
||||
<one-to-one name="successfulBid"
|
||||
property-ref="abc">
|
||||
<formula>id</formula>
|
||||
<formula>c_id</formula>
|
||||
<formula>true</formula>
|
||||
</one-to-one>
|
||||
</class>
|
||||
|
||||
<class name="Bid" table="TBid">
|
||||
<id name="id">
|
||||
<id name="id" column="c_id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="amount"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
package="org.hibernate.orm.test.bidi">
|
||||
|
||||
<class name="Auction" table="TAuction2">
|
||||
<id name="id">
|
||||
<id name="id" column="c_id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="description"/>
|
||||
|
@ -27,7 +27,7 @@
|
|||
</class>
|
||||
|
||||
<class name="Bid" table="TBid2">
|
||||
<id name="id">
|
||||
<id name="id" column="c_id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="amount" scale="19" precision="31"/>
|
||||
|
@ -37,7 +37,7 @@
|
|||
column="auctionId"
|
||||
cascade="persist"/>
|
||||
<property name="successful">
|
||||
<formula>exists(select a.id from TAuction2 a where a.successfulBid=id)</formula>
|
||||
<formula>exists(select a.c_id from TAuction2 a where a.successfulBid=c_id)</formula>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
package="org.hibernate.orm.test.bidi">
|
||||
|
||||
<class name="SpecialAuction" table="TAuction">
|
||||
<id name="id">
|
||||
<id name="id" column="c_id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="description"/>
|
||||
|
@ -25,13 +25,13 @@
|
|||
</bag>
|
||||
<one-to-one name="successfulBid"
|
||||
property-ref="abc">
|
||||
<formula>id</formula>
|
||||
<formula>c_id</formula>
|
||||
<formula>true</formula>
|
||||
</one-to-one>
|
||||
</class>
|
||||
|
||||
<class name="AbstractBid" table="TBid" abstract="true">
|
||||
<id name="id">
|
||||
<id name="id" column="c_id">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
|
|
Loading…
Reference in New Issue