I'm looking for a way to create a webservice with jersey/resteasy without annotations in the POJO/model classes. I generate my model classes with jooq and the model classes are generated each time a change is made in the database.
I found two topics related to my problem: here and here but I would like to know if there is another solution than using another lib/implementation.
any tips? technic? idea?
thank you very much!
EDIT: I add some codes. I have a model class called 'Mushroom' and that consists of 3 fields: mushroom_id, title, description.
I would like to have a JSON representation that looks like:
{
mushroom: {
mushroom_id: 12,
title: "pied de mouton",
description: "très bon champignon!"
}
}
for that, with Resteasy, I need a mushroom class with the following annotations:
@XmlRootElement(name = "mushroom")
public class Mushroom {
private Integer mushroomId;
private String title;
private String description
// for each field I need a getter
// with the XmlElement annotations.
// for 'description' for instance:
@XmlElement
public String getDescription() {
return description;
}
}
BUT, the Mushroom class/entity generated by jooq with my table Mushroom looks like:
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.2.0" },
comments = "This class is generated by jOOQ")
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Mushrooms extends org.jooq.impl.TableImpl<com.spanier.db.tables.records.MushroomsRecord> {
private static final long serialVersionUID = -539518621;
/**
* The singleton instance of <code>public.mushrooms</code>
*/
public static final com.spanier.db.tables.Mushrooms MUSHROOMS = new com.spanier.db.tables.Mushrooms();
/**
* The class holding records for this type
*/
@Override
public java.lang.Class<com.spanier.db.tables.records.MushroomsRecord> getRecordType() {
return com.spanier.db.tables.records.MushroomsRecord.class;
}
/**
* The column <code>public.mushrooms.mushrooms_id</code>.
*/
public final org.jooq.TableField<com.spanier.db.tables.records.MushroomsRecord, java.lang.Integer> MUSHROOMS_ID = createField("mushrooms_id", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this);
/**
* The column <code>public.mushrooms.name</code>.
*/
public final org.jooq.TableField<com.spanier.db.tables.records.MushroomsRecord, java.lang.String> NAME = createField("name", org.jooq.impl.SQLDataType.CHAR.length(50).nullable(false), this);
/**
* The column <code>public.mushrooms.description</code>.
*/
public final org.jooq.TableField<com.spanier.db.tables.records.MushroomsRecord, java.lang.String> DESCRIPTION = createField("description", org.jooq.impl.SQLDataType.VARCHAR, this);
/**
* Create a <code>public.mushrooms</code> table reference
*/
public Mushrooms() {
super("mushrooms", com.spanier.db.Public.PUBLIC);
}
/**
* Create an aliased <code>public.mushrooms</code> table reference
*/
public Mushrooms(java.lang.String alias) {
super(alias, com.spanier.db.Public.PUBLIC, com.spanier.db.tables.Mushrooms.MUSHROOMS);
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.Identity<com.spanier.db.tables.records.MushroomsRecord, java.lang.Integer> getIdentity() {
return com.spanier.db.Keys.IDENTITY_MUSHROOMS;
}
/**
* {@inheritDoc}
*/
@Override
public org.jooq.UniqueKey<com.spanier.db.tables.records.MushroomsRecord> getPrimaryKey() {
return com.spanier.db.Keys.MUSHROOMS_PKEY;
}
/**
* {@inheritDoc}
*/
@Override
public java.util.List<org.jooq.UniqueKey<com.spanier.db.tables.records.MushroomsRecord>> getKeys() {
return java.util.Arrays.<org.jooq.UniqueKey<com.spanier.db.tables.records.MushroomsRecord>>asList(com.spanier.db.Keys.MUSHROOMS_PKEY);
}
/**
* {@inheritDoc}
*/
@Override
public com.spanier.db.tables.Mushrooms as(java.lang.String alias) {
return new com.spanier.db.tables.Mushrooms(alias);
}
}
As you can see the class generated by jooq is: 1. already filled with annotations, if I add new annotation it will be complicated to easily 'read' the class 2. since the jooq class is generated each time I make a modification in the Mushroom table I will lost my annotations (annotations for the json representation) and I will need to edit AGAIN the jooq class.
So Im looking for a way to add the Resteasy annotations (json representation) of the Mushroom generated class in another class/in another file.