You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Fay Wang (JIRA)" <ji...@apache.org> on 2008/04/21 05:22:21 UTC

[jira] Created: (OPENJPA-578) Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
------------------------------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-578
                 URL: https://issues.apache.org/jira/browse/OPENJPA-578
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 1.0.2
            Reporter: Fay Wang
             Fix For: 1.2.0
         Attachments: openjpa.patch

Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

According the OpenJPA documentation the following property should override the default value of VersionStrategy and the specified RowChangeTimestampStrategy should be applied for all entity classes. 

 <property name="openjpa.jdbc.MappingDefaults" 
  	        value="jpa(VersionStrategy=com.ibm.websphere.persistence.RowChangeTimestampStrategy)" />

JPA accepts this property but then it has no effect on Entity mappings if the version field is present.

import javax.persistence.*;
import org.apache.openjpa.persistence.jdbc.VersionStrategy;

@Entity
public class EntityA {
	@Id int id;
	String name;
	double amt;
	@Version java.sql.Timestamp lastUpdate;

For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the NumberVersionStrategy is adopted. 
If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-578) Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fay Wang updated OPENJPA-578:
-----------------------------

    Attachment: openjpa.patch

The attached patch fixes this problem.

> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-578
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-578
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.0.2
>            Reporter: Fay Wang
>             Fix For: 1.2.0
>
>         Attachments: openjpa.patch
>
>
> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> According the OpenJPA documentation the following property should override the default value of VersionStrategy and the specified RowChangeTimestampStrategy should be applied for all entity classes. 
>  <property name="openjpa.jdbc.MappingDefaults" 
>   	        value="jpa(VersionStrategy=com.ibm.websphere.persistence.RowChangeTimestampStrategy)" />
> JPA accepts this property but then it has no effect on Entity mappings if the version field is present.
> import javax.persistence.*;
> import org.apache.openjpa.persistence.jdbc.VersionStrategy;
> @Entity
> public class EntityA {
> 	@Id int id;
> 	String name;
> 	double amt;
> 	@Version java.sql.Timestamp lastUpdate;
> For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the NumberVersionStrategy is adopted. 
> If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-578) Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fay Wang updated OPENJPA-578:
-----------------------------

    Issue Type: Improvement  (was: Bug)

It looks that the current behavior is working as design:

The openjpa.jdbc.MappingDefaults configuration property controls the MappingDefaults interface implementation in use. This is a plugin property (see Section 4, " Plugin Configuration "), so you can substitute your own implementation or configure the existing ones. OpenJPA includes the following standard implementations: 
<snip>
default: This is an alias for the org.apache.openjpa.jdbc.meta.MappingDefaultsImpl class. This default implementation is highly configurable. It has the following properties: 
<snip>
VersionStrategy: The default version strategy for classes without a version field. You can specify a builtin strategy alias or the full class name of a custom version strategy. You can also use OpenJPA's plugin format (see Section 4, " Plugin Configuration ") to pass arguments to the strategy instance. Common strategies are none, state-comparison, timestamp, and version-number, the default. See the org.apache.openjpa.jdbc.meta.strats package for all available strategies. 



> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-578
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-578
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: jdbc
>    Affects Versions: 1.0.2
>            Reporter: Fay Wang
>             Fix For: 1.2.0
>
>         Attachments: openjpa.patch
>
>
> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> According the OpenJPA documentation the following property should override the default value of VersionStrategy and the specified RowChangeTimestampStrategy should be applied for all entity classes. 
>  <property name="openjpa.jdbc.MappingDefaults" 
>   	        value="jpa(VersionStrategy=com.ibm.websphere.persistence.RowChangeTimestampStrategy)" />
> JPA accepts this property but then it has no effect on Entity mappings if the version field is present.
> import javax.persistence.*;
> import org.apache.openjpa.persistence.jdbc.VersionStrategy;
> @Entity
> public class EntityA {
> 	@Id int id;
> 	String name;
> 	double amt;
> 	@Version java.sql.Timestamp lastUpdate;
> For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the NumberVersionStrategy is adopted. 
> If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-578) Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fay Wang resolved OPENJPA-578.
------------------------------

    Resolution: Fixed

We found a workaround to overwrite the current behavior without any openjpa change.

> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-578
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-578
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: jdbc
>    Affects Versions: 1.0.2
>            Reporter: Fay Wang
>             Fix For: 1.2.0
>
>         Attachments: openjpa.patch
>
>
> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> According the OpenJPA documentation the following property should override the default value of VersionStrategy and the specified RowChangeTimestampStrategy should be applied for all entity classes. 
>  <property name="openjpa.jdbc.MappingDefaults" 
>   	        value="jpa(VersionStrategy=com.ibm.websphere.persistence.RowChangeTimestampStrategy)" />
> JPA accepts this property but then it has no effect on Entity mappings if the version field is present.
> import javax.persistence.*;
> import org.apache.openjpa.persistence.jdbc.VersionStrategy;
> @Entity
> public class EntityA {
> 	@Id int id;
> 	String name;
> 	double amt;
> 	@Version java.sql.Timestamp lastUpdate;
> For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the NumberVersionStrategy is adopted. 
> If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-578) Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590967#action_12590967 ] 

Fay Wang commented on OPENJPA-578:
----------------------------------

There is a typo in this example: 
"Instead, the NumberVersionStrategy is adopted. " should be changed to 
"Instead, the TimestampVersionStrategy is adopted."  See below:

@Entity
public class EntityA {
@Id int id;
String name;
double amt;
@Version java.sql.Timestamp lastUpdate;

For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the TimestampVersionStrategy is adopted.
If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy. 

> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-578
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-578
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.0.2
>            Reporter: Fay Wang
>             Fix For: 1.2.0
>
>         Attachments: openjpa.patch
>
>
> Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.
> According the OpenJPA documentation the following property should override the default value of VersionStrategy and the specified RowChangeTimestampStrategy should be applied for all entity classes. 
>  <property name="openjpa.jdbc.MappingDefaults" 
>   	        value="jpa(VersionStrategy=com.ibm.websphere.persistence.RowChangeTimestampStrategy)" />
> JPA accepts this property but then it has no effect on Entity mappings if the version field is present.
> import javax.persistence.*;
> import org.apache.openjpa.persistence.jdbc.VersionStrategy;
> @Entity
> public class EntityA {
> 	@Id int id;
> 	String name;
> 	double amt;
> 	@Version java.sql.Timestamp lastUpdate;
> For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the NumberVersionStrategy is adopted. 
> If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.