CodeGeneration Problems @Override Annotations

155 views
Skip to first unread message

patrik...@gmail.com

unread,
Sep 7, 2014, 11:05:59 AM9/7/14
to jooq...@googlegroups.com
Hello,

after generating some records from the schema the generated code won't compile....

-----------------
public class MachineRunsRecord
extends
org.jooq.impl.UpdatableRecordImpl<hello.database.tables.records.MachineRunsRecord>
implements
org.jooq.Record4<java.lang.Integer, java.lang.String, java.sql.Timestamp, java.sql.Timestamp> {

..........
@Override
public org.jooq.Field<java.lang.Integer> field1() {
}

field1 : "The method field1() of type MachineRunsRecord must override a superclass method"
-----

but in 

------
@Generated("This class was generated using jOOQ-tools")
public interface Record4<T1, T2, T3, T4> extends Record {

    /**
     * Get the first field.
     */
    Field<T1> field1();
--------
The field appears to be there. The Compiler complains that it can't find it, T1 is java.lang.Integer, so it should be available....

Is this a configuration problem, or how can one fix that?
Best,
Patrik

Lukas Eder

unread,
Sep 8, 2014, 2:29:57 AM9/8/14
to jooq...@googlegroups.com
Hello Patrik,

jOOQ requires Java 6 to run. In Java 5, the @Override annotation could only be used for actual method overriding, not implementations of interface methods. That semantics was changed in Java 6.

Even if you may be using Java 6 to compile your program, make sure that you also set your Java compiler to use 1.6 source compatibility.

Best Regards,
Lukas


--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

patrik knoerr

unread,
Sep 8, 2014, 4:31:10 AM9/8/14
to jooq...@googlegroups.com
The code compliance is set to 1.8.. I think the problem could be some interaction with maven / eclipse...
... when it updates the project.

I did not find any hints in the manual that one has to add a source folder to the build path to make the
generated code available. If one does that, the build path is configured in eclipse. But sometimes
eclipse has an outdated project, and it needs to update it from the pom. And then the build path sometimes
gets lost, and the code compliance is set to 1.4. 
Perhaps a small code example how to add a source folder to the pom.xml and the java 1.8 compatibility
would be handy here.

Lukas Eder

unread,
Sep 8, 2014, 6:33:53 AM9/8/14
to jooq...@googlegroups.com
Hi Patrik,

I was actually kind of afraid that you might be using Eclipse. I've run into similar issues in the past, but have never found any consistent ways to reproduce what looks like an m2e bug. Could you explain what you mean by this?

Perhaps a small code example how to add a source folder to the pom.xml and the java 1.8 compatibility
would be handy here.

I'll be more than happy to add a section to the manual if there is a known issue with the Eclipse / Maven integration. Also, if the sample projects are missing something from their pom.xml, I'll happily fix that:

Cheers and thanks for reporting,
Lukas

patrik knoerr

unread,
Sep 8, 2014, 8:58:35 AM9/8/14
to jooq...@googlegroups.com
The problem is that you can add a source folder in eclipse. That works fine. But as soon as you update the project
from the pom.xml in eclipse, the build path entry for the source folder goes away.

Eclipse auto detects anything in generated-sources as a source folder, but only if there is any subfolder when
issuing a mvn eclipse:eclipse.
If you haven't done a mvn generate-sources before that there is no jooq folder (escpecially after "mvn clean")
so the trouble begins.

I guess I one declares a source folder to the pom.xml this might help with the issue.


--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/apiZ2B6chlY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.

Lukas Eder

unread,
Sep 8, 2014, 1:08:09 PM9/8/14
to jooq...@googlegroups.com
Hi Patrik

Thanks for sharing some more details.

2014-09-08 14:58 GMT+02:00 patrik knoerr <patrik...@gmail.com>:
The problem is that you can add a source folder in eclipse. That works fine. But as soon as you update the project
from the pom.xml in eclipse, the build path entry for the source folder goes away.

Hmm, I haven't had that happen to me...
 
Eclipse auto detects anything in generated-sources as a source folder, but only if there is any subfolder when
issuing a mvn eclipse:eclipse.
If you haven't done a mvn generate-sources before that there is no jooq folder (escpecially after "mvn clean")
so the trouble begins.

I guess I one declares a source folder to the pom.xml this might help with the issue.

Yes, I've seen that too, in the past.

m2e hasn't exactly been well-known for its well-integratedness with the Eclipse compiler. Unfortunately, I don't know too much about these things
Reply all
Reply to author
Forward
0 new messages