Announcement Announcement Module
Collapse
No announcement yet.
java.lang.NumberFormatException: For input string: "ID" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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?

    Comment


    • #3
      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

      Comment


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

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

        Comment


        • #5
          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>

          Comment


          • #6
            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.

            Comment


            • #7
              Thanks for a link

              Comment

              Working...
              X