Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1
Mapping documents:
<!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.age.j.soft.hibernate.ReleaseScheduleBean" table="release_schedule">
<id name="releaseScheduleID" column="release_schedule_id">
<generator class="native" />
</id>
<many-to-one name="milestone" column="milestoneID" not-null="true"/>
<!-- <property name="milestoneID" column="milestone_id"/> -->
<property name="feature" column="feature"/>
</class>
</hibernate-mapping>
<!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.age.j.soft.hibernate.MilestoneBean" table="milestone">
<id name="milestoneID" column="milestone_id">
<generator class="native" />
</id>
<property name="productID" column="product_id"/>
<property name="tentativeDate" column="tentative_date" type="date"/>
<property name="number" column="number"/>
<property name="releaseDate" column="release_date" type="date"/>
<property name="maxVersion" column="max_version"/>
<property name="minVersion" column="min_version"/>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
java.sql.SQLException: Unknown column 'releasesch0_.milestoneID' in 'field list'
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
com.mysql.jdbc.Connection.execSQL(Connection.java:3004)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1128)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1222)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
org.hibernate.loader.Loader.doQuery(Loader.java:662)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2145)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
org.springframework.orm.hibernate3.HibernateTemplate$31.doInHibernate(HibernateTemplate.java:853)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:844)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
com.age.j.soft.dao.ReleaseScheduleDAO.getReleaseSchedule(ReleaseScheduleDAO.java:18)
com.age.j.soft.action.ReleaseScheduleAction.prepare(ReleaseScheduleAction.java:17)
Name and version of the database you are using:
MySQL 4
The generated SQL (show_sql=true):
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not execute query; bad SQL grammar [select releasesch0_.release_schedule_id as release1_4_0_, milestoneb1_.milestone_id as milestone1_5_1_, releasesch0_.milestoneID as mileston2_4_0_, releasesch0_.feature as feature4_0_, milestoneb1_.product_id as product2_5_1_, milestoneb1_.tentative_date as tentative3_5_1_, milestoneb1_.number as number5_1_, milestoneb1_.release_date as release5_5_1_, milestoneb1_.max_version as max6_5_1_, milestoneb1_.min_version as min7_5_1_ from release_schedule releasesch0_ inner join milestone milestoneb1_ on releasesch0_.milestoneID=milestoneb1_.milestone_id where milestoneb1_.product_id=? order by milestoneb1_.number]; nested exception is java.sql.SQLException: Unknown column 'releasesch0_.milestoneID' in 'field list
I'm trying to load all ReleaseSchedule beans and all their foreign key associated MilestoneBean by milestoneID for a productID.
(ArrayList<ReleaseScheduleBean>)this.getHibernateTemplate().find("from " + ReleaseScheduleBean.class.getName() + " as rsBean inner join rsBean.milestone as msBean where msBean.productID = ? order by msBean.number" , id);
Not sure what I'm doing wrong. I looked at the examples in the manual.