First steps towards using the auction identifier as the effective primary key into the auctions table.
- A jbidwatcher/trunk/db/015.sql
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionEntry.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionInfo.java view
| 603 | 610 | |
|---|---|---|
| 1536 | 1536 | if(aid != null && aid.length() != 0) { |
| 1537 | 1537 | mAuction = AuctionInfo.findFirstBy("id", aid); |
| 1538 | 1538 | } |
| 1539 | if(mAuction == null && getString("identifier") != null) { | |
| 1540 | mAuction = AuctionInfo.findByIdentifier(getString("identifier")); | |
| 1541 | } | |
| 1539 | 1542 | } |
| 1543 | if(mAuction != null & getString("identifier")==null) { | |
| 1544 | setString("identifier", mAuction.getIdentifier()); | |
| 1545 | saveDB(); | |
| 1546 | } | |
| 1540 | 1547 | return mAuction; |
| 1541 | 1548 | } |
| 1542 | 1549 | |
| 536 | 610 | |
|---|---|---|
| 519 | 519 | return (AuctionInfo) ActiveRecord.findFirstBy(AuctionInfo.class, key, value); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | public static AuctionInfo findByIdentifier(String identifier) { | |
| 523 | return (AuctionInfo) ActiveRecord.findFirstBySQL(AuctionInfo.class, "SELECT * FROM auctions WHERE id IN (SELECT Max(id) FROM auctions WHERE identifier = '" + identifier + "')"); | |
| 524 | } | |
| 525 | ||
| 522 | 526 | public static int precache() { |
| 523 | 527 | return ActiveRecordCache.precacheBySQL(AuctionInfo.class, "SELECT * FROM auctions WHERE id IN (SELECT auction_id FROM entries)", "id", "identifier"); |
| 524 | 528 | } |
