Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] RE: RE: RE: Question on sequencing using

Hi Shashi,
With the following code you should be able to assign sequence numbers prior to transaction commit while still using standard sequencing strategies:

JpaEntityManager jpaEM = JpaHelper.getEntityManager(em);
UnitOfWork uov = jpaEM.getUnitOfWork();
uov.assignSequenceNumbers();  


Best regards,
Reinhard

-----Original Message-----
From: eclipselink-users-request@xxxxxxxxxxx [mailto:eclipselink-users-request@xxxxxxxxxxx] 
Sent: 21 July 2010 09:52
To: eclipselink-users@xxxxxxxxxxx
Subject: eclipselink-users Digest, Vol 35, Issue 25

Send eclipselink-users mailing list submissions to
	eclipselink-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
	https://dev.eclipse.org/mailman/listinfo/eclipselink-users
or, via email, send a message with subject or body 'help' to
	eclipselink-users-request@xxxxxxxxxxx

You can reach the person managing the list at
	eclipselink-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of eclipselink-users digest..."


Today's Topics:

   1. RE: RE: Question on sequencing using	TableGenerator
      (Shashikant Kale)
   2. Tree retrieval using eclipselink (harshavardhan786)
   3. Auto Reply: [eclipselink-users] Tree retrieval using
      eclipselink (neil.hauge@xxxxxxxxxx)
   4. Auto Reply: [eclipselink-users] Tree retrieval using
      eclipselink (gustavo.arango@xxxxxxxxxx)
   5. Creation of temporary tables for MySQL database	update all
      query (ravikirann@xxxxxxxxxxx)


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

Message: 1
Date: Wed, 21 Jul 2010 08:25:23 +0530
From: Shashikant Kale <Shashikant.Kale@xxxxxxxxxxxxxxxx>
Subject: RE: [eclipselink-users] RE: Question on sequencing using
	TableGenerator
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <FDCD1F56CDE47840ADD853365BBE7FEF04C4B58380@indxchange03>
Content-Type: text/plain; charset="utf-8"

Hi Reinhard and Andrei,

Thanks for sharing the information.

I am planning to implement the custom sequencing logic for all our entities in order to generate the ids upfront. The ids are required in order to capture audit details (changes) for an entity. When we traverse deep in the entity hierarchy I require comparison to be done on the objects in a child entity list etc. hence we require ids to be available before committing the data to the database.

As you have explained earlier I am planning to do an Update and then Select in the same transaction in order to get a pre allocated chunk of ids to be assigned for a JVM. Earlier I implemented this using "Select.....from SEQ_TABLE for update" and then update the SEQ_TABLE adding the chunk size. However this has started blocking sessions on the DB (oracle). I assume this would work all fine if not more than 4/5 JVMs try to generate the sequence. However in our development environment each developer would run an application instance and connect to the same DB. This is resulting in contention and the DB doesn't seem to be fast enough to quickly process the serial request for sequence generation.

I would keep you posted after I implement the sequencing logic the way you explaining but using spring jdbc template.

Thanks,
Shashi

-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Reinhard Girstenbrei
Sent: Wednesday, July 21, 2010 2:48 AM
To: eclipselink-users@xxxxxxxxxxx
Subject: [eclipselink-users] RE: Question on sequencing using TableGenerator

Hi Shashi,
Take a look at
http://wiki.eclipse.org/EclipseLink/Examples/JPA/CustomSequencing
You have not explained details about how you want to implement sequencing.
If your implement some sequence that is used by many thread/processes concurrently, then you are likely using a lock in the jvm and/or database which can lead to a lock contention problem which might cause bad insert performance. Therefore you lock for as short time as possible. TopLink sequences use autonomous transactions for the value generation and it uses sequence pre-allocation to lock for as little time as possible.

I hope that helps,
Reinhard

-----Original Message-----
From: eclipselink-users-request@xxxxxxxxxxx [mailto:eclipselink-users-request@xxxxxxxxxxx]
Sent: 20 July 2010 21:21
To: eclipselink-users@xxxxxxxxxxx
Subject: eclipselink-users Digest, Vol 35, Issue 23

Send eclipselink-users mailing list submissions to
        eclipselink-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
        https://dev.eclipse.org/mailman/listinfo/eclipselink-users
or, via email, send a message with subject or body 'help' to
        eclipselink-users-request@xxxxxxxxxxx

You can reach the person managing the list at
        eclipselink-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of eclipselink-users digest..."


Today's Topics:

   1. RE: Question on sequencing using TableGenerator (Shashikant Kale)
   2. Re: Question on sequencing using TableGenerator (Andrei Ilitchev)


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

Message: 1
Date: Wed, 21 Jul 2010 00:17:27 +0530
From: Shashikant Kale <Shashikant.Kale@xxxxxxxxxxxxxxxx>
Subject: RE: [eclipselink-users] Question on sequencing using
        TableGenerator
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <FDCD1F56CDE47840ADD853365BBE7FEF04C4B5835A@indxchange03>
Content-Type: text/plain; charset="us-ascii"

Thanks a lot Andrei and Reinhard.

I asked the query below in order to understand the logic eclipselink handles sequence generation. I am planning to introduce our own sequence generator since we need IDs to be generated upfront before an entity is attached to the em.

I have an option to do this using spring jdbc. However being new to Spring JDBC I am unable to think of a similar implementation using Spring JDBC template wherein I can update preceding select and execute them both in the same transaction.

Can somebody please throw some light?

Regards,
Shashi

From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Andrei Ilitchev
Sent: Tuesday, July 20, 2010 11:24 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Question on sequencing using TableGenerator

In table sequence case, update precedes select and both are executed in the same transaction - so no dirty reads can happen.

On 20/07/2010 12:49 PM, Shashikant Kale wrote:
Hi,

We have been using eclipselink and I have a question wrt eclipselink in clustered environment. We are using TableGenerator for generating primary keys and we use the same sequence for all the entities.

e.g.

      @GeneratedValue(strategy = GenerationType.TABLE, generator = "default")
      @TableGenerator(
            name = "default",
            table = "ID_GENERATOR",
            pkColumnName = "ID_NAME",
            valueColumnName = "ID_VALUE",
            pkColumnValue = "default",
            initialValue = 1,
            allocationSize = 50
      )

However I have found that the Select query is fired without "For Update" clause. Wouldn't this cause issues due to dirty reads across multiple JVMs?

Kindly let me know how this is taken care.

Thanks,
Shashi






________________________________






_______________________________________________

eclipselink-users mailing list

eclipselink-users@xxxxxxxxxxx<mailto:eclipselink-users@xxxxxxxxxxx>

https://dev.eclipse.org/mailman/listinfo/eclipselink-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://dev.eclipse.org/mailman/private/eclipselink-users/attachments/20100720/236c32d8/attachment.html

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

Message: 2
Date: Tue, 20 Jul 2010 15:18:44 -0400
From: Andrei Ilitchev <andrei.ilitchev@xxxxxxxxxx>
Subject: Re: [eclipselink-users] Question on sequencing using
        TableGenerator
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <4C45F694.6030305@xxxxxxxxxx>
Content-Type: text/plain; charset="iso-8859-1"

Table sequence also generates most values before attaching to entities:
the higher allocationSize the rearer trips for the new sequence values
to the db.
It works like that: the first time the new object is created
update/select is executed Eclipselink stores allocationSize sequence
values with the last value being returned by the select, say
UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + allocationSize WHERE
SEQ_NAME = my_seq
SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = my_seq
if it has returned 100, then the sequence values to be used are 51,
52,...,100 (that assumes allocationSize==50)

If you still need a custom sequence I think the only way to do it would
be to derive a new class from
org.eclipse.persistence.sequencing.Sequence class (or one of its subclasses)
Then - because you are using the same sequence for all entities - I
would suggest using default (without any parameters)
  @GeneratedValue
annotation for entities that use the sequence;

and in SessionCustomizer override default sequence with your customary
sequence:
public MySequenceCustomizer implements SessionCustomizer {
    public void customize(Session session) throws Exception {
        session.getPlatform().setDefaultSequence(new MySequence());
    }
}


On 20/07/2010 2:47 PM, Shashikant Kale wrote:
>
> Thanks a lot Andrei and Reinhard.
>
>
>
> I asked the query below in order to understand the logic eclipselink
> handles sequence generation. I am planning to introduce our own
> sequence generator since we need IDs to be generated upfront before an
> entity is attached to the em.
>
>
>
> I have an option to do this using spring jdbc. However being new to
> Spring JDBC I am unable to think of a similar implementation using
> Spring JDBC template wherein I can update preceding select and execute
> them both in the same transaction.
>
>
>
> Can somebody please throw some light?
>
>
>
> Regards,
>
> Shashi
>
>
>
> *From:* eclipselink-users-bounces@xxxxxxxxxxx
> [mailto:eclipselink-users-bounces@xxxxxxxxxxx] *On Behalf Of *Andrei
> Ilitchev
> *Sent:* Tuesday, July 20, 2010 11:24 PM
> *To:* EclipseLink User Discussions
> *Subject:* Re: [eclipselink-users] Question on sequencing using
> TableGenerator
>
>
>
> In table sequence case, update precedes select and both are executed
> in the same transaction - so no dirty reads can happen.
>
> On 20/07/2010 12:49 PM, Shashikant Kale wrote:
>
> Hi,
>
>
>
> We have been using eclipselink and I have a question wrt eclipselink
> in clustered environment. We are using TableGenerator for generating
> primary keys and we use the same sequence for all the entities.
>
>
>
> e.g.
>
>
>
>       @GeneratedValue(strategy = GenerationType.TABLE, generator =
> "default")
>
>       @TableGenerator(
>
>             name = "default",
>
>             table = "ID_GENERATOR",
>
>             pkColumnName = "ID_NAME",
>
>             valueColumnName = "ID_VALUE",
>
>             pkColumnValue = "default",
>
>             initialValue = 1,
>
>             allocationSize = 50
>
>       )
>
>
>
> However I have found that the Select query is fired without "For
> Update" clause. Wouldn't this cause issues due to dirty reads across
> multiple JVMs?
>
>
>
> Kindly let me know how this is taken care.
>
>
>
> Thanks,
>
> Shashi
>
>
> ------------------------------------------------------------------------
>
>
>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://dev.eclipse.org/mailman/private/eclipselink-users/attachments/20100720/2e18897c/attachment.html

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

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


End of eclipselink-users Digest, Vol 35, Issue 23
*************************************************
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

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

Message: 2
Date: Tue, 20 Jul 2010 23:44:53 -0700 (PDT)
From: harshavardhan786 <harshavardhan786@xxxxxxxxx>
Subject: [eclipselink-users] Tree retrieval using eclipselink
To: eclipselink-users@xxxxxxxxxxx
Message-ID: <29222403.post@xxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=us-ascii


Hi,

We have a model like below:

A:B = 1:N ( A has 'N'   B's  ) 
B:C = 1:N
C:B = 1:N
B:D = 1:N

All above are unidirectional relationships.


Now there is tree/graph of objects populated . 
We have enitity id of A. 

Can I get the whole tree/graph for which A is the root in 1 eclipselink/JPA
call ?

Currently we are traversing the whole tree, which is taking more memory .
Are there any ways to acheive the same traversal using memory-cheap
eclipselink/JPA calls ?

Regards,
Harsha


-- 
View this message in context: http://old.nabble.com/Tree-retrieval-using-eclipselink-tp29222403p29222403.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



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

Message: 3
Date: Tue, 20 Jul 2010 23:45:04 -0700 (PDT)
From: neil.hauge@xxxxxxxxxx
Subject: Auto Reply: [eclipselink-users] Tree retrieval using
	eclipselink
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <80700446-8a79-47f0-ae52-76c9b9a5c12c@default>
Content-Type: text/plain; charset=utf-8

I am out of the office with limited access to email from July 20th through the 26th.  Please contact karen.moore or shaun.smith with any urgent Dali related issues.  Please contact roger.striffler with any other urgent issues.

Thanks,
Neil


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

Message: 4
Date: Tue, 20 Jul 2010 23:45:07 -0700 (PDT)
From: gustavo.arango@xxxxxxxxxx
Subject: Auto Reply: [eclipselink-users] Tree retrieval using
	eclipselink
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <17de0c12-8046-4097-b2af-0a83e8b46531@default>
Content-Type: text/plain; charset=utf-8

i,

thanks for your email,
I'm currently off until the 23nd of august 2010.

For Any urgent issue , please contact my manager olivier.mikeladze@xxxxxxxxxx

thanks a lot.

regards,
Gustavo.


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

Message: 5
Date: Wed, 21 Jul 2010 13:21:45 +0530
From: <ravikirann@xxxxxxxxxxx>
Subject: [eclipselink-users] Creation of temporary tables for MySQL
	database	update all query
To: <eclipselink-users@xxxxxxxxxxx>
Message-ID: <008f01cb28a9$90cdedb0$1f01a8c0@ravin>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

   I have a onetomany bidirectional relationship between Customer and Order beans(each customer has multiple orders).
I get an unexpected sql queries generated from a JPQL query in Eclipselink 1.1.1 for MySQL db only.


My JPQL query,

update orders_bidirectional o set o.name = 'ravi' where o.customer.id = :custid



SQL query generated for Oracle db,

UPDATE orders_bidirectional SET NAME = ? WHERE EXISTS(SELECT t1.ID FROM customer_bidirectional t0, orders_bidirectional t1 WHERE ((t0.ID = ?) AND (t0.ID = t1.CUSTOMER_ID)) AND t1.ID = orders_bidirectional.ID)



SQL queries generated for MySQL db,

CREATE TEMPORARY TABLE IF NOT EXISTS TL_orders_bidirectional LIKE orders_bidirectional
INSERT INTO TL_orders_bidirectional (ID, NAME) SELECT t1.ID, ? FROM customer_bidirectional t0, orders_bidirectional t1 WHERE ((t0.ID = ?) AND (t0.ID = t1.CUSTOMER_ID))
UPDATE orders_bidirectional, TL_orders_bidirectional SET orders_bidirectional.NAME = TL_orders_bidirectional.NAME WHERE orders_bidirectional.ID = TL_orders_bidirectional.ID
DELETE FROM TL_orders_bidirectional


Like for other databases, is it possibe to use update all query for MySQL with a single sql query. Generating so many sql queries is
scalability issue for us.


regards,
ravi.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://dev.eclipse.org/mailman/private/eclipselink-users/attachments/20100721/f1a83ef6/attachment.html

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

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


End of eclipselink-users Digest, Vol 35, Issue 25
*************************************************


Back to the top