I've tried that and it's working. I can have auto-generated annotation based
on the table constraints.
Julien D wrote:
>
> Indeed I'm using the eclipse pluggin. I had the same thinking about
> wrinting a pluggin and overwriting the modelfieldGenerated method.
> Something like if introspectedColumn.isNullable so add a @Required
> Annotation. But I don't know if I can do that with a @MaxLength annotation
> because I need to give the maxLength in parameter. Do you think something
> like that will work :
>
> @Override
> public boolean modelFieldGenerated(Field field,TopLevelClass
> topLevelClass, IntrospectedColumn introspectedColumn,IntrospectedTable
> introspectedTable, ModelClassType modelClassType) {
>
> if(introspectedColumn.isNullable()) {
> field.addAnnotation("@Required");
> }
>
> int maxLength = introspectedColumn.getLength();
> StringBuffer maxLengthAnnotation = new StringBuffer();
> maxLengthAnnotation.append("@MaxLength")
> .append("(value=")
> .append(maxLength).append(")");
>
> field.addAnnotation(maxLengthAnnotation.toString());
>
> return true;
> }
>
>
>
>
> Dan Turkenkopf wrote:
>>
>> Hi Julien,
>>
>> I'm assuming since you mention the JavaFileMerger that you're using the
>> Eclipse plugin?
>>
>> I'm not that familiar with how the JavaFileMerger works, but if it's
>> anything like how the SQLMapGenerators work in the standalone version of
>> Ibator, it's going to completely regenerate anything that it originally
>> generated (indicated by the comment and the @ibatorgenerated tag). So it
>> will overwrite your annoation you added. I think the merge tools will
>> keep
>> any additional fields or methods that were not originally generated, but
>> recreate the ones that Ibator is responsible for.
>>
>> Jeff or someone else can correct me if it's different inside Eclipse.
>>
>> One way to make sure this sticks would be to create a plugin that adds
>> the
>> proper annotation for you. You'd want to override the
>> modelFieldGenerated
>> method from IbatorPluginAdapter.
>>
>> Hope this helps,
>>
>> Dan Turkenkopf
>>
>> On Wed, Jan 7, 2009 at 4:01 AM, Julien D <[email protected]> wrote:
>>
>>>
>>> Hi everybody,
>>>
>>> I'm adding annotations in some of my generated java object model but the
>>> JavaFileMerger erase it each time I'm runnig Ibator. Does someone see a
>>> way
>>> around that ?
>>>
>>> Here is an example:
>>>
>>> public class Order implements Serializable {
>>>
>>> /**
>>> * This field was generated by Apache iBATIS ibator. This
>>> field
>>> corresponds to the database
>>> * column SPF_ORDER.ID_ORDER
>>> * @ibatorgenerated
>>> */
>>> @Required
>>> private String orderID;
>>> ...
>>> }
>>>
>>> In the meantime I've tried to insert the annotation above the commentary
>>> but
>>> it's not working either. In that case Ibator will create a duplicate
>>> field
>>> at the end of the file.
>>>
>>> Thanks
>>>
>>> Julien
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Ibator-erasing-custom-annotations-on-private-field-tp21327128p21327128.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Ibator-erasing-custom-annotations-on-private-field-tp21327128p21331790.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.