Hi,
A sample T class would be this one:
> /**
>
> * This class is generated by jOOQ
>
> */
>
> package nl.abbaba.tables.pojos;
>
>
>> /**
>
> * This class is generated by jOOQ.
>
> */
>
> @javax.annotation.Generated(value = {"http://www.jooq.org", "2.4.0"},
>
> comments = "This class is generated by jOOQ")
>
> public class LaborTicket implements java.io.Serializable {
>
>
>> private static final long serialVersionUID = 1821013766;
>
>
>> private java.lang.Integer rowid;
>
> private java.lang.Integer transactionId;
>
> private java.lang.String employeeId;
>
> private java.lang.String departmentId;
>
>
>> public java.lang.Integer getRowid() {
>
> return this.rowid;
>
> }
>
>
>> public void setRowid(java.lang.Integer rowid) {
>
> this.rowid = rowid;
>
> }
>
>
>> public java.lang.Integer getTransactionId() {
>
> return this.transactionId;
>
> }
>
>
>> public void setTransactionId(java.lang.Integer transactionId) {
>
> this.transactionId = transactionId;
>
> }
>
>
>> public java.lang.String getEmployeeId() {
>
> return this.employeeId;
>
> }
>
>
>> public void setEmployeeId(java.lang.String employeeId) {
>
> this.employeeId = employeeId;
>
> }
>
>
>> public java.lang.String getDepartmentId() {
>
> return this.departmentId;
>
> }
>
>
>> public void setDepartmentId(java.lang.String departmentId) {
>
> this.departmentId = departmentId;
>
> }
>
> }
>
>
> This class was generated by using jooQ's code generator with the "pojos"
attribute enabled in the configuration.
The field employeeId relates to a primary key column in the Employee table
(which isn't actually fetched in this use case, but hard-coded.)
Whenever I create a new instance of this POJO and give it a value for the
employeeId which really is valid, it throws an exception whenever I try to
create a record from it
by using SQLServerFactory.newRecord(Tables.LABOR_TICKET,
instanceOfLaborTicket).
In the sample I posted, the generic type R represents an
UpdatableRecordImpl.
I hope this gives somewhat of an idea of what I am trying to do here..
On Tuesday, September 11, 2012 4:02:55 PM UTC+2, Lukas Eder wrote:
>
> Hello,
>
> Can you post more code? E.g. a sample T class (entity). As well as the
> code that is used to produce this problem?
>
> Cheers
> Lukas
>
> 2012/9/11 Rick van Biljouw <[email protected] <javascript:>>:
> > Hi,
> >
> > I'm trying to create a record using POJOs.
> > For that purpose I have the following piece of code:
> >>>
> >>> /**
> >>>
> >>> * Creates a record from a POJO.
> >>>
> >>> *
> >>>
> >>> * @param pojo
> >>>
> >>> * POJO to use for record.
> >>>
> >>> * @return record
> >>>
> >>> */
> >>>
> >>> @SuppressWarnings({ "unchecked" })
> >>>
> >>> private <R extends Record> R newRecord(T entity) {
> >>>
> >>> R record = (R) getFactory().newRecord(getTable(), entity);
> >>>
> >>> return record;
> >>>
> >>> }
> >
> >
> > The POJOs I have are generated by codegen, sadly enough using this code
> > together with one of the POJOs results in the following exception being
> > thrown:
> >>>
> >>> Caused by: org.jooq.exception.DataTypeException: Cannot convert from
> 0201
> >>> (class java.lang.String) to class
> nl.abbabab.tables.records.EmployeeRecord
> >>>
> >>> at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:610)
> >>> ~[jooq-2.5.0-SNAPSHOT.jar:na]
> >>>
> >>> at org.jooq.tools.Convert$ConvertAll.from(Convert.java:564)
> >>> ~[jooq-2.5.0-SNAPSHOT.jar:na]
> >>>
> >>> at org.jooq.tools.Convert.convert0(Convert.java:208)
> >>> ~[jooq-2.5.0-SNAPSHOT.jar:na]
> >>>
> >>> at org.jooq.tools.Convert.convert(Convert.java:200)
> >>> ~[jooq-2.5.0-SNAPSHOT.jar:na]
> >>>
> >>> at org.jooq.tools.Convert.convert(Convert.java:259)
> >>> ~[jooq-2.5.0-SNAPSHOT.jar:na]
> >>>
> >>> at
> org.jooq.impl.AbstractRecord.getValue(AbstractRecord.java:569)
> >>> ~[jooq-2.5.0-SNAPSHOT.jar:na]
> >
> >
> > I'm really at a loss here as to what is causing it..
> > If anyone could tell me where to look to resolve this problem I would
> > appreciate it.
>