0

The code I'm working on is directly manipulating an Entity Object (EO) to insert 5-10k records into the EO's backing table. Yes, it is a bad practice but I don't have time to rewrite the application.

Is there a way, immediately before committing changes, to test to see if a primary key already exists?

Better yet, is there a way to customize the query executed when the transaction is committed? I'd like to add something like INSERT WHERE NOT EXISTS.

My sloppy alternative is to commit each change one at a time which will create undesired app-to-DB traffic.

Please let me know if I can provide any additional information.

Thank you VERY much for reading!

User404
  • 2,152
  • 2
  • 27
  • 35
IdusOrtus
  • 1,005
  • 1
  • 16
  • 24

1 Answers1

1

Better yet, is there a way to customize the query executed when the transaction is committed? I'd like to add something like INSERT WHERE NOT EXISTS.

You can control SQL Statements Entity Objects generate by overriding SQLBuilder class as below: http://www.jobinesh.com/2013/02/customizing-sql-builder-class.html

Florin Marcus
  • 1,657
  • 1
  • 12
  • 11
  • 1
    Thanks! I'll dig into that approach and let you know how it pans out. – IdusOrtus Jun 09 '15 at 16:55
  • This isn't something I can easily do in the team project I'm working on but I will bear it in mind for future solo projects. Thanks again! – IdusOrtus Jun 10 '15 at 20:19