Does your TransactionDao extend GenericDao? Can you reproduce this
problem in a test?
Matt
On 5/31/07, APenrose <[EMAIL PROTECTED]> wrote:
Hi Guys,
I am getting following when trying to save a Transaction model:
*************
javax.servlet.ServletException: null id in {package}.model.Transaction entry
(don't flush the Session after an exception occurs)
net.sf.ehcache.constructs.web.filter.Filter.logThrowable(Filter.java:152)
net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:97)
org.appfuse.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
com.opensymphony.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:42)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:183)
*************
Here is the listing for the transaction model:
@Entity(name = "Transaction")
@Table(name = "transaction", uniqueConstraints = {})
public class Transaction extends BaseObject implements Serializable {
// Fields
protected long id;
protected TransactionType transactionType;
protected User appUser;
protected Double transactionAmount;
protected Date transactionDate;
protected Date dateLastModified;
protected Currency currency;
protected AlternativeRole alternativeRole = new AlternativeRole();
// Constructors
public Transaction() {
}
/** full constructor */
public Transaction(long id, TransactionType transactionType, User
appUser,
Double transactionAmount, Date transactionDate, Date
dateLastModified,
Currency currency){
this.id = id;
this.transactionType = transactionType;
this.appUser = appUser;
this.transactionAmount = transactionAmount;
this.transactionDate = transactionDate;
this.dateLastModified = dateLastModified;
this.currency = currency;
}
// Property accessors
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
public long getId() {
return this.id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
@JoinColumn(name = "userID", unique = false, nullable = false,
insertable = true, updatable = true)
public User getAppUser() {
return appUser;
}
public void setAppUser(User appUser) {
this.appUser = appUser;
}
@OneToOne(cascade = {}, fetch = FetchType.EAGER)
@JoinColumn(name = "alternativeRoleID", unique = false, nullable =
true, insertable = true, updatable = true)
public AlternativeRole getAlternativeRole() {
return alternativeRole;
}
public void setAlternativeRole(AlternativeRole alternativeRole) {
this.alternativeRole = alternativeRole;
}
@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
@JoinColumn(name = "transactionTypeID", unique = false, nullable = true,
insertable = true, updatable = true)
public TransactionType getTransactionType() {
return this.transactionType;
}
public void setTransactionType(TransactionType transactionType) {
this.transactionType = transactionType;
}
@Column(name = "TransactionAmount", unique = false, nullable = true,
insertable = true, updatable = true, precision = 15)
public Double getTransactionAmount() {
return this.transactionAmount;
}
public void setTransactionAmount(Double transactionAmount) {
this.transactionAmount = transactionAmount;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "transactionDate", unique = false, nullable = true,
insertable = true, updatable = true, length = 0)
public Date getTransactionDate() {
return this.transactionDate;
}
public void setTransactionDate(Date transactionDate) {
this.transactionDate = transactionDate;
}
@Temporal(TemporalType.DATE)
@Column(name = "dateLastModified", unique = false, nullable = true,
insertable = true, updatable = true, length = 0)
public Date getDateLastModified() {
return this.dateLastModified;
}
public void setDateLastModified(Date dateLastModified) {
this.dateLastModified = dateLastModified;
}
@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
@JoinColumn(name = "currencyID", unique = false, nullable = true,
insertable = true, updatable = true)
public Currency getCurrency() {
return this.currency;
}
public void setCurrency(Currency currency) {
this.currency = currency;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Transaction transaction = (Transaction) o;
if (id != transaction.id) return false;
if (appUser != null ? !appUser.equals(transaction.appUser) :
transaction.appUser != null) return false;
if (currency != null ? !currency.equals(transaction.currency) :
transaction.currency != null) return false;
if (dateLastModified != null ?
!dateLastModified.equals(transaction.dateLastModified) :
transaction.dateLastModified != null)
return false;
if (transactionAmount != null ?
!transactionAmount.equals(transaction.transactionAmount) :
transaction.transactionAmount != null)
return false;
if (transactionDate != null ?
!transactionDate.equals(transaction.transactionDate) :
transaction.transactionDate != null) return false;
if (transactionType != null ?
!transactionType.equals(transaction.transactionType) :
transaction.transactionType != null) return false;
return true;
}
public int hashCode() {
int result=0;
result = (int) (id ^ (id >>> 32));
result = 31 * result + (transactionType != null ?
transactionType.hashCode() : 0);
result = 31 * result + (appUser != null ? appUser.hashCode() : 0);
result = 31 * result + (transactionAmount != null ?
transactionAmount.hashCode() : 0);
result = 31 * result + (transactionDate != null ?
transactionDate.hashCode() : 0);
result = 31 * result + (dateLastModified != null ?
dateLastModified.hashCode() : 0);
result = 31 * result + (currency != null ? currency.hashCode() :
0);
return result;
}
/**
* Standard toString() method
* @return
*/
public String toString(){
return ReflectionToStringBuilder.reflectionToString(this,
ToStringStyle.DEFAULT_STYLE);
}
}
***********
This is the listing of where I am saving it....
public void storeDonationInformation(Donation donation, Transaction
transaction){
try {
transactionDao.save(transaction);
//donation.addTransaction(transaction);
//donationDao.save(donation);
} catch (DataIntegrityViolationException e) {
log.debug("Data Integrity="+e);
} catch (EntityExistsException e) { // needed for JPA
log.debug("Entity Exists="+e);
}
}
Totally stumped
Any help appreciated
Thanks
Andrew
--
View this message in context:
http://www.nabble.com/don%27t-flush-the-Session-after-an-exception-occurs--tf3847913s2369.html#a10898609
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
http://raibledesigns.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]