Joined subclass - insert failing
diablo341 Mar 21, 2006 1:41 PMI've got a base class, Person, and a joined subclass, Recruiter.
My facelet has input fields that are mapped to the Recruiter subclass.
When I call the create method on the stateful session bean, I get a JDBC error. Why is it complaining about the hireDate field? It's in my form.
Here are some code snippets. Anyone see the problem?
Thanks,
John
@Entity @Inheritance(strategy=InheritanceType.JOINED) @Name("person") @Scope(EVENT) @Table(name="person") public class Person implements Serializable { private long id; private String firstname; private String middlename; private String lastname; private String address; private String socialSecurityNum; private String emailWork; private String emailPersonal; private String phoneWork; private String phoneWorkExtension; private String phoneHome; private String phoneCell; private String jobTitle; public Person() {} @Id(generate=GeneratorType.AUTO) public long getId() { return id; } public void setId(long id) { this.id = id; }
@Entity @Name("recruiter") @Scope(EVENT) @Table(name="recruiter") public class Recruiter extends Person implements Serializable { private java.util.Date hireDate; private int recruiterType; private int terminatedFlag; private java.util.Date terminatedDate; private int commissionType; private double amount; private boolean amountDueFromCommissions; @NotNull public java.util.Date getHireDate() { return hireDate; } public void setHireDate(java.util.Date hireDate) { this.hireDate = hireDate; }
<div class="label"><h:outputLabel for="firstname">First name:</h:outputLabel></div> <div class="input"><h:inputText id="firstname" value="#{recruiter.firstname}"/><br/><span class="errors"><h:message for="firstname" /></span></div> </div> <div class="label"><h:outputLabel for="lastname">Last Name:</h:outputLabel></div> <div class="input"><h:inputText id="lastname" value="#{recruiter.lastname}" /><br/><span class="errors"><h:message for="lastname" /></span></div> </div> <div class="label"><h:outputLabel for="socialSecurityNum">SSN:</h:outputLabel></div> <div class="input"><h:inputText id="socialSecurityNum" value="#{recruiter.socialSecurityNum}" /><br/><span class="errors"><h:message for="socialSecurityNum" /></span></div> </div> <div class="label"><h:outputLabel for="address">Address:</h:outputLabel></div> <div class="input"><h:inputText id="address" value="#{recruiter.address}" /><br/><span class="errors"><h:message for="address" /></span></div> </div> <div class="label"><h:outputLabel for="hireDate">Hire date:</h:outputLabel></div> <div class="input"><h:inputText id="hireDate" value="#{recruiter.hireDate}"><f:convertDateTime type="date"/></h:inputText><br/><span class="errors"><h:message for="hireDate" /></span></div> </div> <div class="entry errors"><h:messages globalOnly="true" /></div> <div class="label"> </div> <div class="input"><h:commandButton value="Create" action="#{createRecruiter.createRecruiter}" class="button"/> <h:commandButton value="Cancel" action="login" class="button"/> </div>
12:16:29,112 INFO [STDOUT] Hibernate: insert into person (address, lastname, socialSecurityNum, firstname, middlename, emailPersonal, emailWork, jobTitle, phoneCell, phoneHome, phoneWork, phoneWorkExtension) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
12:16:29,132 WARN [JDBCExceptionReporter] SQL Error: 1364, SQLState: HY000
12:16:29,132 ERROR [JDBCExceptionReporter] Field 'hireDate' doesn't have a default value
12:16:29,142 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception