This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 226517 - Add existence support to the EclipseLink-ORM.XML Schema
Summary: Add existence support to the EclipseLink-ORM.XML Schema
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: Fixed in 1.0M7
Keywords:
Depends on:
Blocks: 200040
  Show dependency tree
 
Reported: 2008-04-10 10:17 EDT by Guy Pelletier CLA
Modified: 2022-06-09 10:32 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (46.72 KB, patch)
2008-04-15 10:51 EDT, Guy Pelletier CLA
no flags Details | Diff
Proposed patch - updated (46.78 KB, patch)
2008-04-15 11:00 EDT, Guy Pelletier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Guy Pelletier CLA 2008-04-10 10:17:04 EDT
 
Comment 1 Guy Pelletier CLA 2008-04-10 16:21:25 EDT
Changes to query policy to include the existence value.

---------------------------------------------------------------

@Target({TYPE})
@Retention(RUNTIME)
public @interface QueryPolicy {

    /**
     * (Optional) Set the existence check for determining
     * if an insert or update should occur for an object.
     */ 
    ExistenceType existence() default CHECK_CACHE;

    .....

}

public enum JoinFetchType {
    CHECK_CACHE,
    CHECK_DATABASE,
    ASSUME_EXISTENCE,
    ASSUME_NON_EXISTENCE
}

---------------------------------------------------------------

<xsd:complexType name="query-policy">
  <xsd:annotation>
    <xsd:documentation>

      @Target({TYPE})
      @Retention(RUNTIME)
      public @interface QueryPolicy {

        /**
         * (Optional) Set the existence check for determining
         * if an insert or update should occur for an object.
         */ 
        ExistenceType existence() default CHECK_CACHE;

        .....

      }

    </xsd:documentation>
  </xsd:annotation>
  <xsd:sequence>
    .....
  </xsd:sequence>
  <xsd:attribute name="existence" type="orm:existence-type"/>
  .....
</xsd:complexType>


<xsd:simpleType name="existence-type">
  <xsd:restriction base="xsd:token">
    <xsd:enumeration value="CHECK_CACHE" />
    <xsd:enumeration value="CHECK_DATABASE" />
    <xsd:enumeration value="ASSUME_EXISTENCE" />
    <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
  </xsd:restriction>
</xsd:simpleType>
Comment 2 Guy Pelletier CLA 2008-04-10 16:23:12 EDT
Correction:

public enum JoinFetchType {
    CHECK_CACHE,
    CHECK_DATABASE,
    ASSUME_EXISTENCE,
    ASSUME_NON_EXISTENCE
}


Should read

public enum ExistenceType {
    CHECK_CACHE,
    CHECK_DATABASE,
    ASSUME_EXISTENCE,
    ASSUME_NON_EXISTENCE
}
Comment 3 Guy Pelletier CLA 2008-04-11 15:49:03 EDT
This will not be defined within the query-policy, instead it will be defined on its own as follows (configurable on entity and mapped-superclass):

------------------------ ANNOTATION ------------------------

@Target({TYPE})
@Retention(RUNTIME)
public @interface ExistenceChecking {
    /**
     * (Optional) Set the existence check for determining
     * if an insert or update should occur for an object.
     */ 
    ExistenceType value() default CHECK_CACHE;
}

public enum ExistenceType {
    CHECK_CACHE,
    CHECK_DATABASE,
    ASSUME_EXISTENCE,
    ASSUME_NON_EXISTENCE
}

---------------------------- XML ----------------------------

<xsd:complexType name="existence-checking">
  <xsd:annotation>
    <xsd:documentation>

      @Target({TYPE})
      @Retention(RUNTIME)
      public @interface ExistenceChecking {
        /**
         * (Optional) Set the existence check for determining
         * if an insert or update should occur for an object.
         */ 
        ExistenceType type() default CHECK_CACHE;
      }

    </xsd:documentation>
  </xsd:annotation>
  <xsd:attribute name="type" type="orm:existence-type"/>
</xsd:complexType>

<xsd:simpleType name="existence-type">
  <xsd:restriction base="xsd:token">
    <xsd:enumeration value="CHECK_CACHE" />
    <xsd:enumeration value="CHECK_DATABASE" />
    <xsd:enumeration value="ASSUME_EXISTENCE" />
    <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
  </xsd:restriction>
</xsd:simpleType>

Comment 4 Guy Pelletier CLA 2008-04-14 09:20:24 EDT
Since existence-checking is used to set a single value, I don't think we need the complex-type for existence-checking and will add the attribute:

<xsd:attribute name="existence-checking" type="orm:existence-type"/>

to entity and mapped-superclass which maps directly to the type.
Comment 5 Guy Pelletier CLA 2008-04-15 10:51:28 EDT
Created attachment 96085 [details]
Proposed patch
Comment 6 Guy Pelletier CLA 2008-04-15 11:00:02 EDT
Created attachment 96089 [details]
Proposed patch - updated
Comment 7 Guy Pelletier CLA 2008-04-15 11:42:36 EDT
Changes have been submitted.

Reviewed by: Tom Ware

New test (testExistenceCheckingSetting) added to 3 suites:
org.eclipse.persistence.testing.tests.jpa.advanced.AdvancedJPAJunitTest
org.eclipse.persistence.testing.tests.jpa.inherited.EmbeddableSuperclassJunitTest
org.eclipse.persistence.testing.tests.jpa.xml.advanced.EntityMappingsAdvancedJUnitTestCase
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:32:10 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink