Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginner needs help with sql/ejb-ql  RSS feed

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have the following question about sql and ejb-ql:


My boss forces me to use a flat table as above. Here is what happened to this table:

1. A user inserted a record (key and pk == 1)
2. They then updated the same record. You will notice that the "key" is the same (pk == 2)
3. They then updated the update. Key is the same and pk ==3
4. They then inserted a fresh record (pk ==4)
5. Fresh insert again
6. Fresh insert again
7. Delete of immediately previous fresh insert

You will notice that for each action I have an insert into the db (this is for logging/history purposes).

I need to be able to retrieve all record that would have survived the updates and deletes through sql i.e. those marked by a star.


What would be the sql and the ejb-ql for that?

Any clue welcome,

Thanks in advance,

Julien Martin.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple SQL will be


This will not perform good if the data set is huge (which I believe will be). Another approach will be


These SQL will work across products however if you are familiar with Analytical functions you can use them as they will return the results much faster with less cost.

It's been while I looked at ejb-ql, I believe others should help you on this.
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Thanks Purushothaman!
2. Any one has got any idea on how to do that with ejbql 2.1???
Julien.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!