There is no subclasses in use here (The only object they extend is java.lang.Object).
Here is the Journey class:
Code:
package com;
public class Journey
{
private long id;
private String Name;
private long serverTimeStamp;
private Location departureLocation;
public Journey()
{
}
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public String getName()
{
return Name;
}
public void setName(String name)
{
Name = name;
}
public Location getDepartureLocation()
{
return departureLocation;
}
public void setDepartureLocation(Location departureLocation)
{
this.departureLocation = departureLocation;
}
public long getServerTimeStamp()
{
return serverTimeStamp;
}
public void setServerTimeStamp(long serverTimeStamp)
{
this.serverTimeStamp = serverTimeStamp;
}
}
And here is the Location class:
Code:
package com;
public class Location
{
private long id;
private String Name;
private long serverTimeStamp;
public Location()
{
}
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public String getName()
{
return Name;
}
public void setName(String name)
{
Name = name;
}
public long getServerTimeStamp()
{
return serverTimeStamp;
}
public void setServerTimeStamp(long serverTimeStamp)
{
this.serverTimeStamp = serverTimeStamp;
}
}
And here is the mapping for these two classes:
Code:
<hibernate-mapping>
<class name="com.Journey" table="JOURNEY">
<id name="id" column="JOURNEY_ID" type="long">
</id>
<property name="name" />
<property name="serverTimeStamp"/>
<many-to-one name="departureLocation" class="com.Location" cascade="persist" />
</class>
<class name="com.Location" table="LOCATION">
<id name="id" column="LOCATION_ID" type="long">
</id>
<property name="name" />
<property name="serverTimeStamp"/>
</class>
</hibernate-mapping>
And as I said both these queries fails:
session.createQuery("from java.lang.Object obj where obj.class=Journey")
session.createQuery("from java.lang.Object obj where obj.class='com.Journey'")