Results 1 to 7 of 7

Thread: java.lang.NumberFormatException: For input string: "ID"

  1. #1

    Default java.lang.NumberFormatException: For input string: "ID"

    I normally use

    Code:
    return getHibernateTemplate().find("FROM Province order by ID");
    Code:
    <?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.irbeautina.province.Province" table="province">
            <id name="ID" column="ID">
    			<generator class="increment"/>
    		</id>
            <property name="province" type="string">
                <column name="province" length="50" />
            </property>
            <property name="area" type="string">
                <column name="area" length="20" />
             </property>
        </class>
    </hibernate-mapping>
    everything on a project works fine

    now I need to change Query to

    Code:
    select p.ID, p.province, (select count(d.ID) from District d where d.provinceid=p.ID) as dcount FROM Province p order by p.province
    I got an error

    Code:
    java.lang.NumberFormatException: For input string: "ID"
    This is my jsp

    Code:
    <select name="cboprovince" id="cboprovince" onChange="redirect(this.options.selectedIndex)">
                  <c:forEach var="provincelist" items="${provincelist}">
                  <option value=1><c:out value="${provincelist.ID}"/></option>
                  </c:forEach>
            </select>
    How can this error occur, How can I solve this ?

  2. #2

    Default

    Is the NumberFormatException being thrown by the view (the jsp), or in the database query? A stack trace might help pinpoint the problem.

    It could be that you are trying to query on a blank ID value, which is expected to be populated at query time.

    What data type is Province.ID?

  3. #3

    Default

    It was thrown at JPS
    I have checked for null value of ID, there are no null value
    is there any my misstake in query string ?

    i wonder why
    Code:
    FROM Province order by ID
    is works fine
    while
    Code:
    select p.ID, p.province FROM Province p order by p.province
    does not work

    please help

  4. #4

    Default

    The query seems fine to me. What do you mean by JPS?

    Are all of the ID values in the database set correctly?

  5. #5

    Default

    sorry miss spelled I mean jsp
    do you think anything wrong with mapping file or configuration file ?

    Code:
    <beans:property name="hibernateProperties">
    			<beans:props>
    				<beans:prop key="hibernate.connection.charSet">UTF-8</beans:prop>				
    				<beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</beans:prop>
    				<beans:prop key="hibernate.show_sql">true</beans:prop>
    				<beans:prop key="hibernate.cglib.use_reflection_optimizer">true</beans:prop>
    				<beans:prop key="hibernate.use_outer_join">true</beans:prop>
    			</beans:props>
    		</beans:property>

  6. #6

    Default

    I'm not familiar with hibernate.cglib.use_outer_join or hibernate.use_reflection_optimizer, but otherwise it seems fine.

    According to http://www.hibernate.org/hib_docs/nh...ation-optional, hibernate.use_outer_join is deprecated by max_fetch_depth.

  7. #7

    Default

    Thanks for a link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •