[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2546) fetch="select" doesn't work when there are no mapped columns in joined except <key

Daniel D'Alessandro (JIRA) noreply at atlassian.com
Wed Nov 5 05:45:04 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31601#action_31601 ] 

Daniel D'Alessandro commented on HHH-2546:
------------------------------------------

This is still valid in 3.3.1 and it affects any subclass with less than 3 fields apart from the key in it.

eg the example mapping will throw the error if the dummy1 field is taken out of the Test1 mapping.

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.test.Test" table="test">
        <id name="id" column="id" type="java.lang.Long">
            <generator class="sequence">
                <param name="sequence">test_id_seq</param>
            </generator>
        </id>
        <discriminator column="name" type="string"/>

        <subclass name="com.test.Test1" discriminator-value="test1">
            <join table="test1" fetch="select">
                <key column="id"/>
                <property name="placeOfRegistration" column="place_of_registration" type="string"/>
                <property name="registrationNumber" column="registration_number" type="string"/>
                <property name="dummy1" column="dummy1" type="char"/>
            </join>
        </subclass>
    </class>
</hibernate>

> fetch="select" doesn't work when there are no mapped columns in joined except <key
> ----------------------------------------------------------------------------------
>
>                 Key: HHH-2546
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2546
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.3
>         Environment: Windows XP Pro
>            Reporter: Derar Bakr
>   Original Estimate: 10 minutes
>  Remaining Estimate: 10 minutes
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: -2
> 	at java.lang.String.substring(String.java:1768)
> 	at java.lang.String.substring(String.java:1735)
> 	at org.hibernate.persister.entity.AbstractEntityPersister.renderSelect(AbstractEntityPersister.java:2899)
> 	at org.hibernate.persister.entity.SingleTableEntityPersister.generateSequentialSelect(SingleTableEntityPersister.java:647)
> 	at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:696)
> 	....
> Everything is very simple.
> There is stupid code in SelectFragment class, method toFragmentString, line 94. String that is being created there, contains list of fields, like a "f1, f2, f3, ..., fn".
> ", " is being added in every iteration, without check for it is first iteration.
> And in class AbstractEntityPersister., method renderSelect, line 2899, where that method is called, this first ", " is deleted using substring(2). So no check for empty string.
> I suggest to add check :)))
> I just create dynamic mappings programmatically, so create empty join subclass mappings - and in created table there are no fields by default except foreing key.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list