You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig L Russell <Cr...@Sun.COM> on 2007/06/29 22:56:48 UTC

Ease of use for annotations

Another thing about annotations <--> xml.

In xml, we have
<field name="department" column="DEPARTMENT"/>
or
<field name="department" >
   <column name="DEPARTMENT"/>
</field>


In annotations, it's
@Field (columns=@Column(name="DEPARTMENT"))
Department department;

or
@Column(name="DEPARTMENT")
Department department;

It would be nice if we could have @Column("DEPARTMENT") instead of  
@Column(name="DEPARTMENT").

Also @Field (column="DEPARTMENT")

Craig

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Ease of use for annotations

Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,

> This might be controversial, but my Annotations Feature Request #3 is
> to allow the annotation to declare which element is the default if
> there is only one value specified. In this case, it would be "name".

I was thinking of the same thing :-)

Can't see why that should be controversial (and would only require an extra 
keyword allowing on the definition of the annotation to define which element 
is the default). Leaving out the ability (in JDK1.5) to have a null element 
default value is far more controversial IMHO, or not allowing inherited 
annotations, or not allowing cyclic annotations, or ...

> >> Also @Field (column="DEPARTMENT")
> >
> > I've no problem with adding that shortcut String property to @Field
> > but would mention that several shortcuts were removed from non-ORM
> > annotations to try to keep a clean divide between JDO and ORM.
>
> Could you possibly expand more on this?

OK, in the XML metadata some elements have a String shortcut for something 
that could be specified in a sub-element, but allows the shortcut where the 
user just wants the primary thing ... like name of the column rather than 
adding <column>. Maybe I was thinking there were more than there actually 
are. The ones I now see having a quick compare of the DTD and the annotations 
are :-
<field> has "delete-action", yet no "delete-action" annotation element.
<field> has "indexed", yet no "indexed" annotation element.
<field> has "unique", yet no "unique" annotation element.



> > It would be nice to get these into Apache JDO SVN by early next  
> > week if at all possible since I want to get the next JPOX 1.2 beta out 
> > using them 

> Ah, deadlines. I'll see how much I can do in the next few days to wrap 
> things up. 

Thx

-- 
Andy  (Java Persistent Objects - http://www.jpox.org)

Re: Ease of use for annotations

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Andy,

On Jun 29, 2007, at 11:58 PM, Andy Jefferson wrote:

>> It would be nice if we could have @Column("DEPARTMENT") instead of
>> @Column(name="DEPARTMENT").
>
> I've no particular problem with that but would point out that when  
> you need to
> specify more than just the column name you would have
> @Column(value="DEPARTMENT" jdbc-type="BLOB")
> i.e "value" and not "name" (and "name" is more logical when doing  
> that)

I agree.

This might be controversial, but my Annotations Feature Request #3 is  
to allow the annotation to declare which element is the default if  
there is only one value specified. In this case, it would be "name".

Without this feature request, we would define two elements: value()  
and name(). Your annotation processor would have to scold you if you  
specified both name and value; only one is allowed. That way, you  
could have both

@Column("DEPARTMENT") and
@Column(name="DEPARTMENT", jdbc-type="DECIMAL(12,0)")
>
>> Also @Field (column="DEPARTMENT")
>
> I've no problem with adding that shortcut String property to @Field  
> but would
> mention that several shortcuts were removed from non-ORM  
> annotations to try
> to keep a clean divide between JDO and ORM.

Could you possibly expand more on this?
>
> On a related subject, previous discussion of @Table, @SecondaryTable,
> @JoinTable mentioned why is the table name "table" and not "name".  
> I've
> absolutely no problem with it being "name" (and would make JDO2.1  
> annotations
> consistent with JPA1 in this respect). If contemplating the change  
> above for
> @Column, maybe you're also thinking of
> @Table("MYTABLE")
> which would mean the annotation property for the table name would  
> be "value".

And name() as well as value(). See above.
>
> It would be nice to get these into Apache JDO SVN by early next  
> week if at all
> possible since I want to get the next JPOX 1.2 beta out using them

Ah, deadlines. I'll see how much I can do in the next few days to  
wrap things up.

Best,

Craig
>
> -- 
> Andy  (Java Persistent Objects - http://www.jpox.org)

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Ease of use for annotations

Posted by Andy Jefferson <an...@jpox.org>.
> It would be nice if we could have @Column("DEPARTMENT") instead of 
> @Column(name="DEPARTMENT"). 

I've no particular problem with that but would point out that when you need to 
specify more than just the column name you would have
@Column(value="DEPARTMENT" jdbc-type="BLOB")
i.e "value" and not "name" (and "name" is more logical when doing that)

> Also @Field (column="DEPARTMENT")

I've no problem with adding that shortcut String property to @Field but would 
mention that several shortcuts were removed from non-ORM annotations to try 
to keep a clean divide between JDO and ORM.



On a related subject, previous discussion of @Table, @SecondaryTable, 
@JoinTable mentioned why is the table name "table" and not "name". I've 
absolutely no problem with it being "name" (and would make JDO2.1 annotations 
consistent with JPA1 in this respect). If contemplating the change above for 
@Column, maybe you're also thinking of
@Table("MYTABLE")
which would mean the annotation property for the table name would be "value".



It would be nice to get these into Apache JDO SVN by early next week if at all 
possible since I want to get the next JPOX 1.2 beta out using them

-- 
Andy  (Java Persistent Objects - http://www.jpox.org)