Hi all,
I'm new to Hibernate and the forum ;)
I'm trying to make an application using the Spring Framework, Hibernate and Postgre SQL. But I stumbled upon a problem that i can't solve.
The problem I have is that the query that is generated by Hibernate doesn't seem to be a valid one.
Here are the configurations:
Code:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://192.168.2.77/db_fleet?useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="dani"/>
<property name="password" value="dani"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>Address.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
Here is the class that I map to the DB:
Code:
package bus;
public class AddressImp implements Address{
private int addressId;
private String addressFullName;
private double east;
private double north;
private String town;
private String postalCode;
public void setAddressId(int addressId) {
this.addressId = addressId;
}
public int getAddressId() {
return addressId;
}
public void setAddressFullName(String addressFullName) {
this.addressFullName = addressFullName;
}
public String getAddressFullName() {
return addressFullName;
}
public void setEast(double east) {
this.east = east;
}
public double getEast() {
return east;
}
public void setNorth(double north) {
this.north = north;
}
public double getNorth() {
return north;
}
public void setTown(String town) {
this.town = town;
}
public String getTown() {
return town;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getPostalCode() {
return postalCode;
}
}
And this is the xml mapping file:
Code:
<hibernate-mapping>
<class name="bus.AddressImp" table="address">
<id name="AddressId" column="addressId">
<generator class="sequence">
<param name="sequence">address_addressId_seq</param>
</generator>
</id>
<property name="AddressFullName" column="addressFullName" />
<property name="East" column="east" />
<property name="North" column="north" />
<property name="Town" column="town" />
<property name="PostalCode" column="postalCode" />
</class>
</hibernate-mapping>
and this is the database table that i want to map with Hibernate:
Code:
CREATE TABLE address
(
"addressId" serial NOT NULL,
"addressFullName" character(200),
"postalCode" character(5),
town character(30),
"zone" integer,
north double precision,
east double precision,
CONSTRAINT "primaryAddress" PRIMARY KEY ("addressId")
)
And when i try to execute a find("FROM AddressImp");
I get an PSQLException: ERROR: column addressimp0_.addressid does not exist
the query that comes to the postgre server looks like this:
select addressimp0_.addressId as addressId0_, addressimp0_.addressFullName as addressF2_0_, addressimp0_.east as east0_, addressimp0_.north as north0_, addressimp0_.town as town0_, addressimp0_.postalCode as postalCode0_ from address addressimp0_
I really dont know what to do, any help will be appreciated :)