Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

database indexes in EJB3  RSS feed

 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I was wondering how in EJB3 define database indexes on selected columns. Does any of you know how to do that ?

Thanks in advance for helping,

Kind Regards,

KArol Oslowski
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36417
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karol,
EJB 3 generates SQL that runs against your database. So you create the indexes in the database as usual.
 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne!

Thank you very much for your answer. As far as I remember in EJB 2.1 one could define database indexes in descriptor files. I'm not completely positive about that because maybe it was a vendor specific feature....

So you suggest that I should "manually" create indexes in my database?

Kind Regards,

Karol Oslowski
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36417
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karol,
It must have been a database specific feature as that was never in the EJB specification. It's possible your app server vendor still supports that.

When I said "manual", I meant command line. Scroll down to the section on indexes on the w3schools tutorial for the syntax. I recommend that route. It's not hard and it frees you from a vendor feature that may or may not be supported in the future. It also allows you to create the indexes even if you don't use EJB or J2EE in the future. Databases tend to outlive applications.
 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Jeanne,

Thank you very much for your answer. I know how to make database indexes manually, I just thought it may be somehow integrated in EJB so that during any database schema change (what happens relatively often on early stages of developmen) I wouldn't have to add the indexes manually. I suppose I'll have to write the indexes creation in a separate script.

Kind Regards,

k.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!