-->
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.  [ 6 posts ] 
Author Message
 Post subject: SQLError:1364, SQLState:HY000 field not have a default value
PostPosted: Fri Jul 25, 2008 9:40 am 
Newbie

Joined: Sun Mar 19, 2006 4:18 pm
Posts: 17
Location: Turkey
Hibernate version:3

Mapping documents:


/**
* PrWorksheet generated by hbm2java
*/
@Entity
@Table(name = "pr_worksheet", catalog = "timereporting")
public class PrWorksheet implements java.io.Serializable {

private static final long serialVersionUID = 5540290338546120309L;
private Integer seqno;
private PrProject prProject;
private PrLocation prLocation;
private PrStaff prStaffByStatusModifier;
private PrWorkunit prWorkunit;
private PrProjectTask prProjectTask;
private PrStaff prStaffByStaffNo;
private Date reportDate;
private BigDecimal effort;
private BigDecimal overtime;
private String status;
private Date statusModified;

public PrWorksheet() {
}

public PrWorksheet(PrProject prProject, PrLocation prLocation,
PrWorkunit prWorkunit, PrProjectTask prProjectTask,
PrStaff prStaffByStaffNo, Date reportDate, BigDecimal effort) {
this.prProject = prProject;
this.prLocation = prLocation;
this.prWorkunit = prWorkunit;
this.prProjectTask = prProjectTask;
this.prStaffByStaffNo = prStaffByStaffNo;
this.reportDate = reportDate;
this.effort = effort;
}

public PrWorksheet(PrProject prProject, PrLocation prLocation,
PrStaff prStaffByStatusModifier, PrWorkunit prWorkunit,
PrProjectTask prProjectTask, PrStaff prStaffByStaffNo,
Date reportDate, BigDecimal effort, BigDecimal overtime,
String status, Date statusModified) {
this.prProject = prProject;
this.prLocation = prLocation;
this.prStaffByStatusModifier = prStaffByStatusModifier;
this.prWorkunit = prWorkunit;
this.prProjectTask = prProjectTask;
this.prStaffByStaffNo = prStaffByStaffNo;
this.reportDate = reportDate;
this.effort = effort;
this.overtime = overtime;
this.status = status;
this.statusModified = statusModified;
}

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "SEQNO", unique = true, nullable = false)
public Integer getSeqno() {
return this.seqno;
}

public void setSeqno(Integer seqno) {
this.seqno = seqno;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROJ_CODE", nullable = false)
public PrProject getPrProject() {
return this.prProject;
}

public void setPrProject(PrProject prProject) {
this.prProject = prProject;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "LOC_CODE", nullable = false)
public PrLocation getPrLocation() {
return this.prLocation;
}

public void setPrLocation(PrLocation prLocation) {
this.prLocation = prLocation;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "STATUS_MODIFIER")
public PrStaff getPrStaffByStatusModifier() {
return this.prStaffByStatusModifier;
}

public void setPrStaffByStatusModifier(PrStaff prStaffByStatusModifier) {
this.prStaffByStatusModifier = prStaffByStatusModifier;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "WORK_UNIT", nullable = false)
public PrWorkunit getPrWorkunit() {
return this.prWorkunit;
}

public void setPrWorkunit(PrWorkunit prWorkunit) {
this.prWorkunit = prWorkunit;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns( {
@JoinColumn(name = "PROJ_CODE", referencedColumnName = "PROJ_CODE", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "PRTASK_CODE", referencedColumnName = "PRTASK_CODE", nullable = false, insertable = false, updatable = false) })
public PrProjectTask getPrProjectTask() {
return this.prProjectTask;
}

public void setPrProjectTask(PrProjectTask prProjectTask) {
this.prProjectTask = prProjectTask;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "STAFF_NO", nullable = false)
public PrStaff getPrStaffByStaffNo() {
return this.prStaffByStaffNo;
}

public void setPrStaffByStaffNo(PrStaff prStaffByStaffNo) {
this.prStaffByStaffNo = prStaffByStaffNo;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "REPORT_DATE", nullable = false, length = 19)
public Date getReportDate() {
return this.reportDate;
}

public void setReportDate(Date reportDate) {
this.reportDate = reportDate;
}

@Column(name = "EFFORT", nullable = false, precision = 10)
public BigDecimal getEffort() {
return this.effort;
}

public void setEffort(BigDecimal effort) {
this.effort = effort;
}

@Column(name = "OVERTIME", precision = 10)
public BigDecimal getOvertime() {
return this.overtime;
}

public void setOvertime(BigDecimal overtime) {
this.overtime = overtime;
}

@Column(name = "STATUS", length = 1)
public String getStatus() {
return this.status;
}

public void setStatus(String status) {
this.status = status;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "STATUS_MODIFIED", length = 19)
public Date getStatusModified() {
return this.statusModified;
}

public void setStatusModified(Date statusModified) {
this.statusModified = statusModified;
}

}



/**
* PrProjectTask generated by hbm2java
*/
@Entity
@Table(name = "pr_project_task", catalog = "timereporting")
public class PrProjectTask implements java.io.Serializable {

private static final long serialVersionUID = 7946332587725218980L;
private PrProjectTaskId id;
private PrProject prProject;
private String taskName;
private String taskType;
private String mandatoryWu;
private String preferredLocation;
private String notvisible;
private Set<PrDcr> prDcrs = new HashSet<PrDcr>(0);
private Set<PrWorksheet> prWorksheets = new HashSet<PrWorksheet>(0);
private Set<PrProjectRole> prProjectRoles = new HashSet<PrProjectRole>(0);

public PrProjectTask() {
}

public PrProjectTask(PrProjectTaskId id, PrProject prProject,
String taskName, String taskType, String preferredLocation) {
this.id = id;
this.prProject = prProject;
this.taskName = taskName;
this.taskType = taskType;
this.preferredLocation = preferredLocation;
}

public PrProjectTask(PrProjectTaskId id, PrProject prProject,
String taskName, String taskType, String mandatoryWu,
String preferredLocation, String notvisible, Set<PrDcr> prDcrs,
Set<PrWorksheet> prWorksheets, Set<PrProjectRole> prProjectRoles) {
this.id = id;
this.prProject = prProject;
this.taskName = taskName;
this.taskType = taskType;
this.mandatoryWu = mandatoryWu;
this.preferredLocation = preferredLocation;
this.notvisible = notvisible;
this.prDcrs = prDcrs;
this.prWorksheets = prWorksheets;
this.prProjectRoles = prProjectRoles;
}

@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "projCode", column = @Column(name = "PROJ_CODE", nullable = false, length = 80)),
@AttributeOverride(name = "prtaskCode", column = @Column(name = "PRTASK_CODE", nullable = false, length = 80)) })
public PrProjectTaskId getId() {
return this.id;
}

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROJ_CODE", nullable = false, insertable = false, updatable = false)
public PrProject getPrProject() {
return this.prProject;
}

public void setPrProject(PrProject prProject) {
this.prProject = prProject;
}

@Column(name = "TASK_NAME", nullable = false, length = 100)
public String getTaskName() {
return this.taskName;
}

public void setTaskName(String taskName) {
this.taskName = taskName;
}

@Column(name = "TASK_TYPE", nullable = false, length = 45)
public String getTaskType() {
return this.taskType;
}

public void setTaskType(String taskType) {
this.taskType = taskType;
}

@Column(name = "MANDATORY_WU", length = 10)
public String getMandatoryWu() {
return this.mandatoryWu;
}

public void setMandatoryWu(String mandatoryWu) {
this.mandatoryWu = mandatoryWu;
}

@Column(name = "PREFERRED_LOCATION", nullable = false, length = 80)
public String getPreferredLocation() {
return this.preferredLocation;
}

public void setPreferredLocation(String preferredLocation) {
this.preferredLocation = preferredLocation;
}

@Column(name = "NOTVISIBLE", length = 10)
public String getNotvisible() {
return this.notvisible;
}

public void setNotvisible(String notvisible) {
this.notvisible = notvisible;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "prProjectTask")
public Set<PrDcr> getPrDcrs() {
return this.prDcrs;
}

public void setPrDcrs(Set<PrDcr> prDcrs) {
this.prDcrs = prDcrs;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "prProjectTask")
public Set<PrWorksheet> getPrWorksheets() {
return this.prWorksheets;
}

public void setPrWorksheets(Set<PrWorksheet> prWorksheets) {
this.prWorksheets = prWorksheets;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "prProjectTask")
public Set<PrProjectRole> getPrProjectRoles() {
return this.prProjectRoles;
}

public void setPrProjectRoles(Set<PrProjectRole> prProjectRoles) {
this.prProjectRoles = prProjectRoles;
}

}





Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:


16:14:08,175 ERROR [STDERR] 97109 [http-127.0.0.1-8080-2] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1364, SQLState: HY000
16:14:08,175 ERROR [STDERR] 97109 [http-127.0.0.1-8080-2] ERROR org.hibernate.util.JDBCExceptionReporter - Field 'PRTASK_CODE' doesn't have a default value
16:14:08,175 ERROR [PrWorksheetHome] persist failed
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [com.atosorigin.utils.pojo.PrWorksheet]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:182)
at com.atosorigin.utils.pojo.PrWorksheetHome.persist(PrWorksheetHome.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
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:110)
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.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
at $Proxy136.persist(Unknown Source)
at com.atosorigin.utils.bean.PrWorksheetBean.insertPrWorksheet(PrWorksheetBean.java:104)
at com.atosorigin.timereport.servlet.MainController.doInsertWorksheet(MainController.java:830)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.atosorigin.timereport.servlet.MainController.service(MainController.java:153)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
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:262)
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:446)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [com.atosorigin.utils.pojo.PrWorksheet]
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.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2163)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2643)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:622)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:600)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
... 58 more
Caused by: java.sql.SQLException: Field 'PRTASK_CODE' doesn't have a default value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:72)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
... 73 more



Name and version of the database you are using:Mysql 5.1.12-beta-community-nt via TCP/IP

The generated SQL (show_sql=true):
Hibernate: insert into timereporting.pr_worksheet (EFFORT, OVERTIME, LOC_CODE, PROJ_CODE, STAFF_NO, STATUS_MODIFIER, WORK_UNIT, REPORT_DATE, STATUS, STATUS_MODIFIED) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


I am using like this;

prWorksheet.setPrProjectTask(new PrProjectTask());
prWorksheet.getPrProjectTask().setId(new PrProjectTaskId());
prWorksheet.getPrProjectTask().getId().setProjCode(request.getParameter("proj_code"));
prWorksheet.getPrProjectTask().getId().setPrtaskCode(request.getParameter("prtask_code"));

I have tried also this;
prWorksheet.setPrProjectTask(prProjectTaskInstance.findById(new PrProjectTaskId(request.getParameter("proj_code"),request.getParameter("prtask_code"))));

Please help me :(


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 1:52 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Could you set a default value for PRTASK_COD at the database level? I think that's what it's asking for.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:39 pm 
Newbie

Joined: Sun Mar 19, 2006 4:18 pm
Posts: 17
Location: Turkey
When I was using, I am sure, I have set all fields. I have print out befero persist function and I have seen fields value. So why I need to set a default value for PRTASK_CODE at the database level? It is nullable false but I have set field's value before use it.

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns( {
@JoinColumn(name = "PROJ_CODE", referencedColumnName = "PROJ_CODE", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "PRTASK_CODE", referencedColumnName = "PRTASK_CODE", nullable = false, insertable = false, updatable = false) })
public PrProjectTask getPrProjectTask() {
return this.prProjectTask;
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 27, 2008 3:39 pm 
Newbie

Joined: Sun Mar 19, 2006 4:18 pm
Posts: 17
Location: Turkey

KEY `pr_worksheet_fk_pr_project_task` (`PROJ_CODE`,`PRTASK_CODE`),

CONSTRAINT `pr_worksheet_fk_pr_project_task` FOREIGN KEY (`PROJ_CODE`, `PRTASK_CODE`) REFERENCES `pr_project_task` (`PROJ_CODE`, `PRTASK_CODE`)

ENGINE=InnoDB DEFAULT CHARSET=utf8;


There is a multi column foreign key and when hibernate genereting sql one of this column value is not cosidered.

insert into timereporting.pr_worksheet (EFFORT, OVERTIME, LOC_CODE, PROJ_CODE, STAFF_NO, STATUS_MODIFIER, WORK_UNIT, REPORT_DATE, STATUS, STATUS_MODIFIED) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

in this sql PRTASK_CODE is not in here, but it has a value.

PROJ_CODE is also a foreign key for another table.

KEY `pr_worksheet_fk_pr_project` (`PROJ_CODE`),

CONSTRAINT `pr_worksheet_fk_pr_project` FOREIGN KEY (`PROJ_CODE`) REFERENCES `pr_project` (`PROJ_CODE`),

Please help :(


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 28, 2008 3:36 am 
Newbie

Joined: Sun Mar 19, 2006 4:18 pm
Posts: 17
Location: Turkey
I have changed the annotation,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns( {
@JoinColumn(name = "PROJ_CODE", referencedColumnName = "PROJ_CODE", nullable = false),
@JoinColumn(name = "PRTASK_CODE", referencedColumnName = "PRTASK_CODE", nullable = false) })
public PrProjectTask getPrProjectTask() {
return this.prProjectTask;
}

I have removed insertable false - updatable false properties,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROJ_CODE", nullable = false, insertable = false, updatable = false)
public PrProject getPrProject() {
return this.prProject;
}

I have changed other join's PROJ_CODE's insertable, updatable properties to the false.

Hibernate tools generated entity bean is not considering if one column used as foregin key for multi tables.

I think this is a bug.


Top
 Profile  
 
 Post subject: Re: SQLError:1364, SQLState:HY000 field not have a default value
PostPosted: Sat Nov 20, 2010 8:50 am 
Newbie

Joined: Thu Oct 07, 2010 10:16 am
Posts: 4
Hi, I have exactly the same problem, is there a solution?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.