Hello,
I'm using hibernate 2 with Spring 2 and Oracle 9i to create a web application.
I'm getting the following error when trying to save an object.
Quote:
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: Could not save object; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-02289: sequence does not exist
Although I created a sequence.
Please, find below my class and hibernate mapping file.
Class:
Code:
public class User {
private Long id;
private String firstName;
private String lastName;
private String email;
private String password;
private String organization;
private String streetAddress;
private String city;
private String country;
private String state;
private String telephone;
private Date registrationTimestamp;
private Boolean isActive;
/**
* @return Returns the isActive.
*/
public Boolean getIsActive() {
return isActive;
}
/**
* @param isActive The isActive to set.
*/
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
/**
* @return Returns the city.
*/
public String getCity() {
return city;
}
/**
* @param city The city to set.
*/
public void setCity(String city) {
this.city = city;
}
/**
* @return Returns the country.
*/
public String getCountry() {
return country;
}
/**
* @param country The country to set.
*/
public void setCountry(String country) {
this.country = country;
}
/**
* @return Returns the email.
*/
public String getEmail() {
return email;
}
/**
* @param email The email to set.
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return Returns the firstName.
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName The firstName to set.
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return Returns the id.
*/
public Long getId() {
return id;
}
/**
* @param id The id to set.
*/
public void setId(Long id) {
this.id = id;
}
/**
* @return Returns the lastName.
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName The lastName to set.
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return Returns the organization.
*/
public String getOrganization() {
return organization;
}
/**
* @param organization The organization to set.
*/
public void setOrganization(String organization) {
this.organization = organization;
}
/**
* @return Returns the password.
*/
public String getPassword() {
return password;
}
/**
* @param password The password to set.
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return Returns the registrationTimestamp.
*/
public Date getRegistrationTimestamp() {
return registrationTimestamp;
}
/**
* @param registrationTimestamp The registrationTimestamp to set.
*/
public void setRegistrationTimestamp(Date registrationTimestamp) {
this.registrationTimestamp = registrationTimestamp;
}
/**
* @return Returns the state.
*/
public String getState() {
return state;
}
/**
* @param state The state to set.
*/
public void setState(String state) {
this.state = state;
}
/**
* @return Returns the streetAddress.
*/
public String getStreetAddress() {
return streetAddress;
}
/**
* @param streetAddress The streetAddress to set.
*/
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
/**
* @return Returns the telephone.
*/
public String getTelephone() {
return telephone;
}
/**
* @param telephone The telephone to set.
*/
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String toString() {
return new ToStringBuilder(this)
.append("firstName", this.firstName)
.append("lastName", this.lastName)
.append("email", this.email)
.toString();
}
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof User)) {
return false;
}
User rhs = (User) o;
return new EqualsBuilder()
.append("firstName", this.firstName)
.append("lastName", this.lastName)
.append("email", this.email)
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder(2090939697, 874530185)
.append( this.firstName)
.append(this.lastName)
.append(this.email)
.toHashCode();
}
}
Hibernate hbm:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!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.userManagement.model.User"
table="SIK_IMAGE_FF_ACCOUNT"
>
<id
name="id"
column="ID"
type="java.lang.Long"
>
<generator class="sequence">
<param name="sequence">USER_SEQUENCE</param>
</generator>
</id>
<property
name="firstName"
type="java.lang.String"
update="true"
insert="true"
column="FIRST_NAME"
/>
<property
name="lastName"
type="java.lang.String"
update="true"
insert="true"
column="LAST_NAME"
/>
<property
name="email"
type="java.lang.String"
update="true"
insert="true"
column="EMAIL"
/>
<property
name="password"
type="java.lang.String"
update="true"
insert="true"
column="PASSWORD"
/>
<property
name="organization"
type="java.lang.String"
update="true"
insert="true"
column="ORGANIZATION"
/>
<property
name="streetAddress"
type="java.lang.String"
update="true"
insert="true"
column="STREET_ADDRESS"
/>
<property
name="city"
type="java.lang.String"
update="true"
insert="true"
column="CITY"
/>
<property
name="country"
type="java.lang.String"
update="true"
insert="true"
column="COUNTRY"
/>
<property
name="state"
type="java.lang.String"
update="true"
insert="true"
column="STATE"
/>
<property
name="telephone"
type="java.lang.String"
update="true"
insert="true"
column="TELEPHONE"
/>
<property
name="registrationTimestamp"
type="java.util.Date"
update="true"
insert="true"
column="REGISTRATION_TIMESTAMP"
/>
<property
name="isActive"
type="java.lang.Boolean"
update="true"
insert="true"
column="ACTIVATED"
/>
</class>
</hibernate-mapping>
The sequence USER_SEQUENCE is already created but I still get the same error.
Thanks.