@VersionColumns usage

9 Messages Forum Options Options
Embed this topic
Permalink
Dinkar Rao
@VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Hi,

The OpenJPA manual very briefly talks about the @VersionColumns annotation, but its usage is not clear. I have an entity that tries to use this annotation (below), but I get back an exception when I run the mapping tool against it:

"Exception in thread "main" <openjpa-1.3.0-SNAPSHOT-runknown fatal user error>
org.apache.openjpa.util.MetaDataException: For "entities.Employee<version>", expected 1 column(s),
but found 2."

1. What is the correct usage for @VersionColumns ?
2. Is it to be used when the underlying database supports multiple surrogate version columns for the same table ? Or...
3. ...is it to be used in conjunction with secondary tables, where the primary and each secondary table have their own database-generated surrogate version column ? In the snippet below, it doesn't matter whether I have the @SecondaryTable annotation or not - I get the exception from the mapping tool anyway.

Thanks,
Dinkar

@Entity
@VersionColumns({@VersionColumn(name="vcol1"),@VersionColumn(name="vcol2")})
@SecondaryTable(name="EADDRESS", pkJoinColumns=@PrimaryKeyJoinColumn(name="EMPID"))
public class Employee {
        @Id @GeneratedValue(strategy=GenerationType.AUTO)
        private int empid;
        private String name;
       
        @Column(table="EADDRESS")
        private String street1;
        @Column(table="EADDRESS")
        private String street2;
        @Column(table="EADDRESS")
        private String city;
        @Column(table="EADDRESS")
        private int zipcode;
}
Pinaki Poddar
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Hi,
  This error is reproducible. Please raise a JIRA issue.
 

Dinkar Rao
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Done - opened OPENJPA-697.

But I'm not clear on the usage, still. What are the semantics of
@VersionColumns ?

Thanks,
Dinkar

On Thu, Aug 21, 2008 at 3:51 PM, Pinaki Poddar <ppoddar@...> wrote:

>
> Hi,
>  This error is reproducible. Please raise a JIRA issue.
>
>
>
> --
> View this message in context: http://n2.nabble.com/%40VersionColumns-usage-tp736463p741558.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>
Pinaki Poddar
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Hi,
  A recent commit on OPENJPA-697 upgrades the version column strategy for multiple numeric columns.
A simple test case is available in the commit set as demonstration of usage. When a version value is represented as multiple column values, comparison of the version values poses some open questions.
Currently, the comparison of v1 and v2 (when v1 and v2 are array of version column values) is as follows:
  if (compare(v1[i], v2[i]) = x for all i then return x
  if (compare(v1[i], v2[i]) = x for some i and 0 for all other i then return x
  otherwise return 1.

A bit heuristic but am ready to listen to other ideas.
Craig L Russell
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
I'm not clear on the use case for multiple version columns. Does  
anyone have an example of where it is useful?

Craig

On Aug 25, 2008, at 7:58 AM, Pinaki Poddar wrote:

>
> Hi,
>  A recent commit on OPENJPA-697 upgrades the version column strategy  
> for
> multiple numeric columns.
> A simple test case is available in the commit set as demonstration  
> of usage.
> When a version value is represented as multiple column values,  
> comparison of
> the version values poses some open questions.
> Currently, the comparison of v1 and v2 (when v1 and v2 are array of  
> version
> column values) is as follows:
>  if (compare(v1[i], v2[i]) = x for all i then return x
>  if (compare(v1[i], v2[i]) = x for some i and 0 for all other i then  
> return
> x
>  otherwise return 1.
>
> A bit heuristic but am ready to listen to other ideas.
>
> --
> View this message in context: http://n2.nabble.com/%40VersionColumns-usage-tp736463p781659.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
Craig L Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@...
P.S. A good JDO? O, Gasp!



smime.p7s (3K) Download Attachment
Pinaki Poddar
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Hi Craig,
  Perhaps, in legacy situations, where the JPA application may not own all the version columns and other apps may be updating one or more of them. But I can not remember seeing a real use case.

  Regards --
Dinkar Rao
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Another unconfirmed use case I heard of, different than the one
assumed in Pinaki's fix, is that @Versions is specified when an
entity's fields are spread across multiple secondary tables. The
primary table and each secondary table have their own version columns,
and when any attribute of a table is updated, JPA tracks the
corresponding version field for that table.

Thanks,
Dinkar

On Mon, Aug 25, 2008 at 10:25 AM, Pinaki Poddar <ppoddar@...> wrote:

>
> Hi Craig,
>  Perhaps, in legacy situations, where the JPA application may not own all
> the version columns and other apps may be updating one or more of them. But
> I can not remember seeing a real use case.
>
>  Regards --
> --
> View this message in context: http://n2.nabble.com/%40VersionColumns-usage-tp736463p782044.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>
Pinaki Poddar
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Hi,
  That is a good use case -- how about augmenting/adding a test case to verify that my fix will cope or not when version columns span across primary and secondary tables?

Dinkar Rao
Re: @VersionColumns usage
Reply Threaded MoreMore options
Print post
Permalink
Will try it out and post back the results soon.

Thanks,
Dinkar

On Mon, Aug 25, 2008 at 11:13 AM, Pinaki Poddar
<ml-user+12775-1797880253@...> wrote:

> Hi,
>   That is a good use case -- how about augmenting/adding a test case to
> verify that my fix will cope or not when version columns span across primary
> and secondary tables?
>
>
>
> ________________________________
> Subscribed to Nabble @
> http://n2.nabble.com/%40VersionColumns-usage-tp736463p736463.html
> To unsubscribe, click here.
>