:)
In the meanwhile I've played with it so things have now changed
Hibernate version: 2.1.3
Mapping document
Code:
<hibernate-mapping package="gr.forthnet.openseas.models">
<class name="Port" table="ports">
<id name="abbreviation" column="port_id" type="java.lang.String" unsaved-value="null" length="32">
<generator class="hilo"/>
</id>
<property name="name" column="port_name" not-null="true" />
<bag name="destinations" table="fromto" cascade="all" inverse="true" lazy="false">
<key column="originID"/>
<many-to-many column="destinationID" class="Port" />
</bag>
</class>
</hibernate-mapping>
Stack traceCode:
Hibernate: select distinct port0_.port_id as port_id, port0_.port_name as port_name from ports port0_
Hibernate: select destinatio0_.destinationID as destinat2___, destinatio0_.originID as originID__, port1_.port_id as port_id0_, port1_.port_name as port_name0_ from fromto destinatio0_ inner join ports port1_ on destinatio0_.destinationID=port1_.port_id where destinatio0_.originID=?
WARN - SQL Error: 102, SQLState: 42000
ERROR - Incorrect syntax near 'inner'.
WARN - SQL Error: 102, SQLState: 42000
ERROR - Incorrect syntax near 'inner'.
ERROR - could not initialize collection: [gr.forthnet.openseas.models.Port.destinations#ORE]
com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near 'inner'.
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2429)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1865)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:201)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:182)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1401)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1386)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:69)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:83)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3259)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3114)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1505)
at gr.forthnet.openseas.HiberDatabase.performQuery(HiberDatabase.java:54)
at gr.forthnet.openseas.DatabaseClient.generatePorts(DatabaseClient.java:185)
at gr.forthnet.openseas.DatabaseClient.getPorts(DatabaseClient.java:64)
at gr.forthnet.openseas.DatabaseClient.generateGreekSortedPorts(DatabaseClient.java:203)
at gr.forthnet.openseas.DatabaseClient.getGreekSortedPorts(DatabaseClient.java:72)
at gr.forthnet.openseas.pages.main.Main.updateContext(Main.java:53)
at gr.forthnet.openseas.servlets.BaseServlet.handleRequest(BaseServlet.java:85)
at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest(VelocityViewServlet.java:425)
at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doGet(VelocityViewServlet.java:392)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Sybaseports table
Code:
Column_name Type Length Prec Scale Nulls Default_name Rule_name Identity
--------------- ------- --------- ------- -------- -------- --------------- ------------ -----------
port_id varchar 6 (null) (null) false (null) (null) false
port_name varchar 40 (null) (null) false (null) (null) false
port_greek_name varchar 25 (null) (null) false (null) (null) false
port_int_name varchar 25 (null) (null) false (null) (null) false
area_id varchar 10 (null) (null) true (null) (null) false
dest_id varchar 10 (null) (null) true (null) (null) false
fromto table
Code:
Column_name Type Length Prec Scale Nulls Default_name Rule_name Identity
-------------- -------- --------- ------- -------- -------- --------------- ------------ -----------
id smallint 2 (null) (null) true (null) (null) false
origin varchar 50 (null) (null) true (null) (null) false
originID varchar 6 (null) (null) true (null) (null) false
destination varchar 50 (null) (null) true (null) (null) false
destinationID varchar 6 (null) (null) true (null) (null) false
areaID smallint 2 (null) (null) true (null) (null) false
Java classesCode:
public class Port extends Location
{
public Port()
{
super();
}
public Port(String abbreviation, String name)
{
super(abbreviation, name);
}
}
Code:
protected List origins = new ArrayList();
protected List destinations = new ArrayList();
public Location()
{
super();
}
public Location(String abbreviation, String name)
{
super(abbreviation, name);
}
public List getOrigins() {
return origins;
}
public void setOrigins(List origins) {
this.origins = origins;
}
public List getDestinations() {
return destinations;
}
public void setDestinations(List destinations) {
this.destinations = destinations;
}
}
Code:
public class Entity
{
protected String abbreviation;
protected String name;
public Entity()
{
this("", "*");
}
public Entity(String abbreviation, String name)
{
setAbbreviation(abbreviation);
setName(name);
}
public String getAbbreviation() {
return this.abbreviation;
}
public String getName() {
return this.name;
}
public void setAbbreviation(String abbreviation) {
if(abbreviation == null)
this.abbreviation = "";
else
this.abbreviation = abbreviation;
}
public void setName(String name) {
if(name == null)
this.name = "*";
else
this.name = name;
}
}