Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @UnionPartitioning does not seem to be using the correct connection pool
@UnionPartitioning does not seem to be using the correct connection pool [message #676447] Sat, 04 June 2011 09:28 Go to next message
Mark Ashworth is currently offline Mark Ashworth
Messages: 8
Registered: March 2010
Junior Member
When using @UnionPartitioning with the default and named connection pools and the entity is loaded from the named connection pool, the UPDATE to the entity seems to be routed to the default connection instead of the named connection.

The reason for the named connection is to load the entities from the main database schema and from the archive schema. What might be better that getting the UPDATE to route to the archive schema, is be able to have an listener that is able to set a property on the result domain entity that it is a archived entity and therefore no UPDATE/DELETE function should be performed.

I have the following entity mapping:-

@Entity(name = "TrainingCourse")
@Access(AccessType.FIELD)
@Table(name = "course")
@UnionPartitioning(
        name="UnionPartitioningAllNodes",
        /*Do not replicate changes to all data sources*/
        replicateWrites=false)
@Partitioned("UnionPartitioningAllNodes")
public class TrainingCourse extends DomainEntity {

@Id
@Column(name = "course_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

....

@Version
@Column(name = "version")
}


And I have setup the following connection in the persistence.xml

<property name="eclipselink.connection-pool.archive.jtaDataSource" value="yellowfire.training.archive.ds" />


Thank you in advance
Re: @UnionPartitioning does not seem to be using the correct connection pool [message #676846 is a reply to message #676447] Mon, 06 June 2011 13:40 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The UnionPartitioning as you have specified it will only affect reads, so write will go to the default data-source.

In order to partition the writes, you must use some other form of partitioning. Perhaps add an isArchived field and use ValuePartitioning on it.
But, if the objects are suppose to be read-only anyway, then it seems your application code is wrong if it is changing the objects. If you don't change the objects, then they will not be updated.


James : Wiki : Book : Blog : Twitter
icon7.gif  Re: @UnionPartitioning does not seem to be using the correct connection pool [message #676979 is a reply to message #676846] Tue, 07 June 2011 03:26 Go to previous messageGo to next message
Mark Ashworth is currently offline Mark Ashworth
Messages: 8
Registered: March 2010
Junior Member
Hi James,

Re-reading the Javadoc of @UnionPartitioning I see that it does not mention that this partition will be used for writes except for replicateWrites which lead me to believe that the writes were happening on this partition scheme.

I did not want to change the archive objects, just thought it was a weird side-effect of using @UnionPartitioning. You suggestion of using @ValuePartition is a excellent one and will use it for other scenarios.

Thank you for your assistance,
Mark P Ashworth
Re: @UnionPartitioning does not seem to be using the correct connection pool [message #685829 is a reply to message #676979] Mon, 20 June 2011 06:07 Go to previous messageGo to next message
Mark Ashworth is currently offline Mark Ashworth
Messages: 8
Registered: March 2010
Junior Member
Hi James,

Is there a way to configure the @UnionPartitioning in the orm.xml file because the wiki only describes how to configure the other partitioning schemes?

Regards,
Mark P Ashworth
Re: @UnionPartitioning does not seem to be using the correct connection pool [message #685883 is a reply to message #685829] Mon, 20 June 2011 10:01 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can configure any of the partitioning schemes in xml. @UnionPartitioning is <union-partitioning>. The orm.xml mirrors the annotations for partitioning the same as everything else.

The EclipseLink orm.xml schemas are here,

http://wiki.eclipse.org/EclipseLink/XSDs


James : Wiki : Book : Blog : Twitter
Re: @UnionPartitioning does not seem to be using the correct connection pool [message #687879 is a reply to message #685883] Thu, 23 June 2011 08:55 Go to previous message
Mark Ashworth is currently offline Mark Ashworth
Messages: 8
Registered: March 2010
Junior Member
Hi,

Thank you for you help, it is much appreciated.

In EclipseLink 2.2, the scrollable cursor seems to be able to only read the data from the default session *which is understandable*, and I was wondering if in future releases of EclipseLink if the ScrollableCursor would be able to read from the union partition.

Regards,
Mark P Ashworth
Previous Topic:Parent Child Heirarchy with Subclasses Bug
Next Topic:SQL String from JPQL Query
Goto Forum:
  


Current Time: Thu Aug 21 00:43:37 EDT 2014

Powered by FUDForum. Page generated in 0.01593 seconds