-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: could not insert exception when trying to insert a row
PostPosted: Fri Mar 19, 2010 11:26 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
Hi

I have an entity Fce which has certain parameters which are defined in the DB as number(1). They take a single numeric integer as a value. Now the entity I have is defined as follows:

@Entity
@Table(name = "FCE", schema = "KARYN")
public class Fce implements java.io.Serializable {

private static final long serialVersionUID = 1L;

private FceId id;
private Short courseTotal;
private String semOrder;
private BigDecimal objective;
private BigDecimal exams;
private BigDecimal assignments;
private BigDecimal lectures;
private BigDecimal discussions;
private BigDecimal relevancy;
private BigDecimal overallRating;
private Date dateEntered;
private String enteredBy;
private String updatedBy;
private Date dateUpdated;
private CourseOffering courseOffering;
}

I am referring to the parameters defined as BigDecimal in this entity. They are defined as Number(1) in the DB. And they are all nullable. Now I am trying to insert a row into the table FCE. And i get the following exception.

java.lang.NoSuchMethodError: edu.cmu.heinz.hcis.entity.Fce.getObjective()Ljava/lang/Short;
javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: java.lang.NoSuchMethodError: edu.cmu.heinz.hcis.entity.Fce.getObjective()Ljava/lang/Short;
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:387)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.ejb.EJBTransactionRolledbackException: java.lang.NoSuchMethodError: edu.cmu.heinz.hcis.entity.Fce.getObjective()Ljava/lang/Short;
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:94)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:108)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:117)
at $Proxy256.addFacultyCourseEval(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
at org.javassist.tmp.java.lang.Object_$$_javassist_3.addFacultyCourseEval(Object_$$_javassist_3.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 49 more


It seems like it is expecting Short. The problem is that it does not end there. I have changed it to Short and tried it as well.

Then I get the following error.


------------------------------------------------------------------------------------------------------------------
Hibernate:
select
fce0_.COURSE_NO as COURSE1_46_0_,
fce0_.SECTION as SECTION46_0_,
fce0_.SEMESTER as SEMESTER46_0_,
fce0_.SEQUENCE_NO as SEQUENCE4_46_0_,
fce0_.ASSIGNMENTS as ASSIGNME5_46_0_,
fce0_.COURSE_TOTAL as COURSE6_46_0_,
fce0_.DATE_ENTERED as DATE7_46_0_,
fce0_.DATE_UPDATED as DATE8_46_0_,
fce0_.DISCUSSIONS as DISCUSSI9_46_0_,
fce0_.ENTERED_BY as ENTERED10_46_0_,
fce0_.EXAMS as EXAMS46_0_,
fce0_.LECTURES as LECTURES46_0_,
fce0_.OBJECTIVE as OBJECTIVE46_0_,
fce0_.OVERALL_RATING as OVERALL14_46_0_,
fce0_.RELEVANCY as RELEVANCY46_0_,
fce0_.SEM_ORDER as SEM16_46_0_,
fce0_.UPDATED_BY as UPDATED17_46_0_
from
KARYN.FCE fce0_
where
fce0_.COURSE_NO=?
and fce0_.SECTION=?
and fce0_.SEMESTER=?
and fce0_.SEQUENCE_NO=?
16:52:37,495 INFO [STDOUT] Hibernate:
select
fceins0_.COURSE_NO as COURSE1_57_0_,
fceins0_.FAC_ID as FAC2_57_0_,
fceins0_.SECTION as SECTION57_0_,
fceins0_.SEMESTER as SEMESTER57_0_,
fceins0_.SEQUENCE_NO as SEQUENCE5_57_0_,
fceins0_.ANSWER_N_FEEDBACK as ANSWER6_57_0_,
fceins0_.CRITICAL_THINKING as CRITICAL7_57_0_,
fceins0_.DATE_ENTERED as DATE8_57_0_,
fceins0_.DATE_UPDATED as DATE9_57_0_,
fceins0_.ENTERED_BY as ENTERED10_57_0_,
fceins0_.ENTHUSIASM as ENTHUSIASM57_0_,
fceins0_.OVERALL_RATING as OVERALL12_57_0_,
fceins0_.SEM_ORDER as SEM13_57_0_,
fceins0_.UPDATED_BY as UPDATED14_57_0_
from
KARYN.FCE_INS fceins0_
where
fceins0_.COURSE_NO=?
and fceins0_.FAC_ID=?
and fceins0_.SECTION=?
and fceins0_.SEMESTER=?
and fceins0_.SEQUENCE_NO=?
16:52:37,495 INFO [STDOUT] Hibernate:
select
fceta0_.COURSE_NO as COURSE1_56_0_,
fceta0_.SECTION as SECTION56_0_,
fceta0_.SEMESTER as SEMESTER56_0_,
fceta0_.SEQUENCE_NO as SEQUENCE4_56_0_,
fceta0_.TA_ID as TA5_56_0_,
fceta0_.AVAILABLITY as AVAILABL6_56_0_,
fceta0_.COMMUNICATION as COMMUNIC7_56_0_,
fceta0_.DATE_ENTERED as DATE8_56_0_,
fceta0_.DATE_UPDATED as DATE9_56_0_,
fceta0_.ENTERED_BY as ENTERED10_56_0_,
fceta0_.ENTHUSIASM as ENTHUSIASM56_0_,
fceta0_.OVERALL_RATING as OVERALL12_56_0_,
fceta0_.PATIENCE as PATIENCE56_0_,
fceta0_.SEM_ORDER as SEM14_56_0_,
fceta0_.UPDATED_BY as UPDATED15_56_0_
from
KARYN.FCE_TA fceta0_
where
fceta0_.COURSE_NO=?
and fceta0_.SECTION=?
and fceta0_.SEMESTER=?
and fceta0_.SEQUENCE_NO=?
and fceta0_.TA_ID=?
16:52:37,557 INFO [STDOUT] Hibernate:
insert
into
KARYN.FCE
(ASSIGNMENTS, COURSE_TOTAL, DATE_ENTERED, DATE_UPDATED, DISCUSSIONS, ENTERED_BY, EXAMS, LECTURES, OBJECTIVE, OVERALL_RATING, RELEVANCY, SEM_ORDER, UPDATED_BY, COURSE_NO, SECTION, SEMESTER, SEQUENCE_NO)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:52:37,557 INFO [STDOUT] Invalid Value: #0--semester
16:52:37,557 INFO [STDOUT] Invalid Value: #0--courseNo
16:52:37,557 INFO [STDOUT] Invalid Value: #0--section
16:52:37,557 INFO [STDOUT] mode is viewFacCourseEval
16:52:37,636 INFO [STDOUT] Hibernate:
insert
into
KARYN.FCE
(ASSIGNMENTS, COURSE_TOTAL, DATE_ENTERED, DATE_UPDATED, DISCUSSIONS, ENTERED_BY, EXAMS, LECTURES, OBJECTIVE, OVERALL_RATING, RELEVANCY, SEM_ORDER, UPDATED_BY, COURSE_NO, SECTION, SEMESTER, SEQUENCE_NO)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:52:37,636 INFO [ShortType] could not bind value '3' to parameter: 1; The statement is closed.
16:52:37,636 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
16:52:37,636 ERROR [JDBCExceptionReporter] The statement is closed.
16:52:37,636 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [edu.cmu.heinz.hcis.entity.Fce]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:523)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1406)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:146)
at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:341)
at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:241)
at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

------------------------------------------------------------------------------------------------------------------

If you see this it is trying to insert data into FCE but there is a mismatch from the data I am trying to insert and to the column it is trying to insert it into.

I dont see the reason why there should be this mismatch. I generated the entity through Hibernate Tools. So what is going on here. Kindly do let me know if anyone has any idea.

I would look forward for a quick response on this pls.

thanks
Sai


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 4:25 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Do you (how do you) annotate private FceId id or its getter method?
Do you (how do you) annotate class FceId ?
This (relevant) informations are missing


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 9:05 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
This is rest of the class of Fce.

public Fce() {
}

public Fce(FceId id) {
this.id = id;
}

public Fce(FceId id, Short courseTotal, String semOrder, Short objective,
Short exams, Short assignments, Short lectures,
Short discussions, Short relevancy, Short overallRating,
Date dateEntered, String enteredBy, String updatedBy,
Date dateUpdated, CourseOffering courseOffering) {
this.id = id;
this.courseTotal = courseTotal;
this.semOrder = semOrder;
this.objective = objective;
this.exams = exams;
this.assignments = assignments;
this.lectures = lectures;
this.discussions = discussions;
this.relevancy = relevancy;
this.overallRating = overallRating;
this.dateEntered = dateEntered;
this.enteredBy = enteredBy;
this.updatedBy = updatedBy;
this.dateUpdated = dateUpdated;
this.courseOffering = courseOffering;
}

@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "semester", column = @Column(name = "SEMESTER", nullable = false, length = 3)),
@AttributeOverride(name = "courseNo", column = @Column(name = "COURSE_NO", nullable = false, length = 8)),
@AttributeOverride(name = "section", column = @Column(name = "SECTION", nullable = false, length = 2)),
@AttributeOverride(name = "sequenceNo", column = @Column(name = "SEQUENCE_NO", nullable = false, precision = 11, scale = 0)) })
@NotNull
public FceId getId() {
return this.id;
}

public void setId(FceId id) {
this.id = id;
}

@Column(name = "COURSE_TOTAL", precision = 3, scale = 0)
public Short getCourseTotal() {
return this.courseTotal;
}

public void setCourseTotal(Short courseTotal) {
this.courseTotal = courseTotal;
}

@Column(name = "SEM_ORDER", length = 5)
@Length(max = 5)
public String getSemOrder() {
return this.semOrder;
}

public void setSemOrder(String semOrder) {
this.semOrder = semOrder;
}

@Column(name = "OBJECTIVE", precision = 1, scale = 0)
public Short getObjective() {
return this.objective;
}

public void setObjective(Short objective) {
this.objective = objective;
}

@Column(name = "EXAMS", precision = 1, scale = 0)
public Short getExams() {
return this.exams;
}

public void setExams(Short exams) {
this.exams = exams;
}

@Column(name = "ASSIGNMENTS", precision = 1, scale = 0)
public Short getAssignments() {
return this.assignments;
}

public void setAssignments(Short assignments) {
this.assignments = assignments;
}

@Column(name = "LECTURES", precision = 1, scale = 0)
public Short getLectures() {
return this.lectures;
}

public void setLectures(Short lectures) {
this.lectures = lectures;
}

@Column(name = "DISCUSSIONS", precision = 1, scale = 0)
public Short getDiscussions() {
return this.discussions;
}

public void setDiscussions(Short discussions) {
this.discussions = discussions;
}

@Column(name = "RELEVANCY", precision = 1, scale = 0)
public Short getRelevancy() {
return this.relevancy;
}

public void setRelevancy(Short relevancy) {
this.relevancy = relevancy;
}

@Column(name = "OVERALL_RATING", precision = 1, scale = 0)
public Short getOverallRating() {
return this.overallRating;
}

public void setOverallRating(Short overallRating) {
this.overallRating = overallRating;
}

@Temporal(TemporalType.DATE)
@Column(name = "DATE_ENTERED", length = 7)
public Date getDateEntered() {
return this.dateEntered;
}

public void setDateEntered(Date dateEntered) {
this.dateEntered = dateEntered;
}

@Column(name = "ENTERED_BY", length = 40)
@Length(max = 40)
public String getEnteredBy() {
return this.enteredBy;
}

public void setEnteredBy(String enteredBy) {
this.enteredBy = enteredBy;
}

@Column(name = "UPDATED_BY", length = 40)
@Length(max = 40)
public String getUpdatedBy() {
return this.updatedBy;
}

public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}

@Temporal(TemporalType.DATE)
@Column(name = "DATE_UPDATED", length = 7)
public Date getDateUpdated() {
return this.dateUpdated;
}

public void setDateUpdated(Date dateUpdated) {
this.dateUpdated = dateUpdated;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns( {
@JoinColumn(name = "SEMESTER", referencedColumnName = "SEMESTER", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "COURSE_NO", referencedColumnName = "COURSE_NO", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "SECTION", referencedColumnName = "SECTION", nullable = false, insertable = false, updatable = false) })
public CourseOffering getCourseOffering() {
return courseOffering;
}

public void setCourseOffering(CourseOffering courseOffering) {
this.courseOffering = courseOffering;
}

As you see I do annotate class private getter method Fceid. Also let me post you the embedded class Fceid.
------------------------------------------------------------------------------------------------------------------


@Embeddable
public class FceId implements java.io.Serializable {

private String semester;
private String courseNo;
private String section;
private long sequenceNo;

public FceId() {
}

public FceId(String semester, String courseNo, String section,
long sequenceNo) {
this.semester = semester;
this.courseNo = courseNo;
this.section = section;
this.sequenceNo = sequenceNo;
}

@Column(name = "SEMESTER", nullable = false, length = 3)
@NotNull
@Length(max = 3)
public String getSemester() {
return this.semester;
}

public void setSemester(String semester) {
this.semester = semester;
}

@Column(name = "COURSE_NO", nullable = false, length = 8)
@NotNull
@Length(max = 8)
public String getCourseNo() {
return this.courseNo;
}

public void setCourseNo(String courseNo) {
this.courseNo = courseNo;
}

@Column(name = "SECTION", nullable = false, length = 2)
@NotNull
@Length(max = 2)
public String getSection() {
return this.section;
}

public void setSection(String section) {
this.section = section;
}

@Column(name = "SEQUENCE_NO", nullable = false, precision = 11, scale = 0)
@NotNull
public long getSequenceNo() {
return this.sequenceNo;
}

public void setSequenceNo(long sequenceNo) {
this.sequenceNo = sequenceNo;
}

public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof FceId))
return false;
FceId castOther = (FceId) other;

return ((this.getSemester() == castOther.getSemester()) || (this
.getSemester() != null
&& castOther.getSemester() != null && this.getSemester()
.equals(castOther.getSemester())))
&& ((this.getCourseNo() == castOther.getCourseNo()) || (this
.getCourseNo() != null
&& castOther.getCourseNo() != null && this
.getCourseNo().equals(castOther.getCourseNo())))
&& ((this.getSection() == castOther.getSection()) || (this
.getSection() != null
&& castOther.getSection() != null && this.getSection()
.equals(castOther.getSection())))
&& (this.getSequenceNo() == castOther.getSequenceNo());
}

public int hashCode() {
int result = 17;

result = 37 * result
+ (getSemester() == null ? 0 : this.getSemester().hashCode());
result = 37 * result
+ (getCourseNo() == null ? 0 : this.getCourseNo().hashCode());
result = 37 * result
+ (getSection() == null ? 0 : this.getSection().hashCode());
result = 37 * result + (int) this.getSequenceNo();
return result;
}


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 9:29 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Did you remember to regenerate also the schema on database, after converting the BigDecimal to Short?


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 9:35 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
Well see here is the thing

Do you think there is a problem with how the fields are defined in the DB.

Because the first time I used Hibernate reverse engineering to generate the entity. It generated with Boolean as the type for those fields. Now it can't be Boolean, since in the DB the values it takes is 3, 4, 5,... etc. Any integer, so I tried first BigDecimal, tried Integer, tried Short. When I give any type other than Short, it complains it wants Short.

And when I give it Short
I get the following error:

----------------------------------------------------------------------------------------------------------------------
Hibernate:
select
fce0_.COURSE_NO as COURSE1_46_0_,
fce0_.SECTION as SECTION46_0_,
fce0_.SEMESTER as SEMESTER46_0_,
fce0_.SEQUENCE_NO as SEQUENCE4_46_0_,
fce0_.ASSIGNMENTS as ASSIGNME5_46_0_,
fce0_.COURSE_TOTAL as COURSE6_46_0_,
fce0_.DATE_ENTERED as DATE7_46_0_,
fce0_.DATE_UPDATED as DATE8_46_0_,
fce0_.DISCUSSIONS as DISCUSSI9_46_0_,
fce0_.ENTERED_BY as ENTERED10_46_0_,
fce0_.EXAMS as EXAMS46_0_,
fce0_.LECTURES as LECTURES46_0_,
fce0_.OBJECTIVE as OBJECTIVE46_0_,
fce0_.OVERALL_RATING as OVERALL14_46_0_,
fce0_.RELEVANCY as RELEVANCY46_0_,
fce0_.SEM_ORDER as SEM16_46_0_,
fce0_.UPDATED_BY as UPDATED17_46_0_
from
KARYN.FCE fce0_
where
fce0_.COURSE_NO=?
and fce0_.SECTION=?
and fce0_.SEMESTER=?
and fce0_.SEQUENCE_NO=?
16:52:37,495 INFO [STDOUT] Hibernate:
select
fceins0_.COURSE_NO as COURSE1_57_0_,
fceins0_.FAC_ID as FAC2_57_0_,
fceins0_.SECTION as SECTION57_0_,
fceins0_.SEMESTER as SEMESTER57_0_,
fceins0_.SEQUENCE_NO as SEQUENCE5_57_0_,
fceins0_.ANSWER_N_FEEDBACK as ANSWER6_57_0_,
fceins0_.CRITICAL_THINKING as CRITICAL7_57_0_,
fceins0_.DATE_ENTERED as DATE8_57_0_,
fceins0_.DATE_UPDATED as DATE9_57_0_,
fceins0_.ENTERED_BY as ENTERED10_57_0_,
fceins0_.ENTHUSIASM as ENTHUSIASM57_0_,
fceins0_.OVERALL_RATING as OVERALL12_57_0_,
fceins0_.SEM_ORDER as SEM13_57_0_,
fceins0_.UPDATED_BY as UPDATED14_57_0_
from
KARYN.FCE_INS fceins0_
where
fceins0_.COURSE_NO=?
and fceins0_.FAC_ID=?
and fceins0_.SECTION=?
and fceins0_.SEMESTER=?
and fceins0_.SEQUENCE_NO=?
16:52:37,495 INFO [STDOUT] Hibernate:
select
fceta0_.COURSE_NO as COURSE1_56_0_,
fceta0_.SECTION as SECTION56_0_,
fceta0_.SEMESTER as SEMESTER56_0_,
fceta0_.SEQUENCE_NO as SEQUENCE4_56_0_,
fceta0_.TA_ID as TA5_56_0_,
fceta0_.AVAILABLITY as AVAILABL6_56_0_,
fceta0_.COMMUNICATION as COMMUNIC7_56_0_,
fceta0_.DATE_ENTERED as DATE8_56_0_,
fceta0_.DATE_UPDATED as DATE9_56_0_,
fceta0_.ENTERED_BY as ENTERED10_56_0_,
fceta0_.ENTHUSIASM as ENTHUSIASM56_0_,
fceta0_.OVERALL_RATING as OVERALL12_56_0_,
fceta0_.PATIENCE as PATIENCE56_0_,
fceta0_.SEM_ORDER as SEM14_56_0_,
fceta0_.UPDATED_BY as UPDATED15_56_0_
from
KARYN.FCE_TA fceta0_
where
fceta0_.COURSE_NO=?
and fceta0_.SECTION=?
and fceta0_.SEMESTER=?
and fceta0_.SEQUENCE_NO=?
and fceta0_.TA_ID=?
16:52:37,557 INFO [STDOUT] Hibernate:
insert
into
KARYN.FCE
(ASSIGNMENTS, COURSE_TOTAL, DATE_ENTERED, DATE_UPDATED, DISCUSSIONS, ENTERED_BY, EXAMS, LECTURES, OBJECTIVE, OVERALL_RATING, RELEVANCY, SEM_ORDER, UPDATED_BY, COURSE_NO, SECTION, SEMESTER, SEQUENCE_NO)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:52:37,557 INFO [STDOUT] Invalid Value: #0--semester
16:52:37,557 INFO [STDOUT] Invalid Value: #0--courseNo
16:52:37,557 INFO [STDOUT] Invalid Value: #0--section
16:52:37,557 INFO [STDOUT] mode is viewFacCourseEval
16:52:37,636 INFO [STDOUT] Hibernate:
insert
into
KARYN.FCE
(ASSIGNMENTS, COURSE_TOTAL, DATE_ENTERED, DATE_UPDATED, DISCUSSIONS, ENTERED_BY, EXAMS, LECTURES, OBJECTIVE, OVERALL_RATING, RELEVANCY, SEM_ORDER, UPDATED_BY, COURSE_NO, SECTION, SEMESTER, SEQUENCE_NO)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:52:37,636 INFO [ShortType] could not bind value '3' to parameter: 1; The statement is closed.
16:52:37,636 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
16:52:37,636 ERROR [JDBCExceptionReporter] The statement is closed.
16:52:37,636 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [edu.cmu.heinz.hcis.entity.Fce]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:523)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1406)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:146)
at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:341)
at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:241)
at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
--------------------------------------------------------------------------------------------------------------
The important part is the stack trace when it is trying to insert into FCE. Maybe it will give you some idea..

P.S: Thanks for the quick reply
thanks
Sai


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 9:53 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
Do you believe I should regenerate the schema on the DB


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 10:34 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Do you believe I should regenerate the schema on the DB


Yes.
As first thing I would regenerate a fresh schema on another (Test)-DB,
to check if the error happens also on that db with aligned schema.


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 10:42 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
Well this is what I have done

I wrote a standalone class, created a connection to DB, created a Statement Object.

Wrote a insert statement in the Statement object.
and called stmt.execute.

It executed it and when I went and checked the DB, I see the new row.

Sai


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Mon Mar 22, 2010 10:51 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
it is happening through the standalone class, but it is not inserting through the application.

Now in the app, I set the id in the following manner when I load the page:

The sequence number is set to the highest sequence number+1 for that course, section, semester. And the course, section and semester to be the same as the other entries in that table.

I print the values of what i am inserting and they are exactly the same as the one's I am sending it.

Sai


Top
 Profile  
 
 Post subject: Re: could not insert exception when trying to insert a row
PostPosted: Wed Mar 24, 2010 11:57 am 
Newbie

Joined: Fri Oct 30, 2009 4:30 pm
Posts: 16
Is there anyone who could help me on this. I am still facing the problem..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.