1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package port_type_daogen;
import java.sql.*;
import java.util.*;
//import java.math.*;
import java.sql.Connection;
/**
* Board_ref Data Access Object (DAO).
* This class contains all database handling that is needed to
* permanently store and retrieve Board_ref object instances.
*/
public class Board_refDao {
// Cache contents:
private boolean cacheOk;
private List cacheData;
/**
* Constructor for Dao. This constructor will only reset cache.
* If extended Dao classes are generated, it is important to
* make sure resetCache() will be called in constructor.
*/
public Board_refDao() {
resetCache();
}
/**
* resetCache-method. This is important method when caching is used
* to keep data in Dao instance. This method must be called whenever
* the data in table has been changed. This method will mark current
* cache to be outdated and next time when cacheable data will be
* retrieved from database, the cache will be rebuilt. Please note
* that using Dao-cache can have remarkable performace boost or it may
* not help at all. It all depends on the amount of data and the rate
* that data is being changed.
*/
public final void resetCache() {
cacheOk = false;
cacheData = null;
}
/**
* createValueObject-method. This method is used when the Dao class needs
* to create new value object instance. The reason why this method exists
* is that sometimes the programmer may want to extend also the valueObject
* and then this method can be overrided to return extended valueObject.
* NOTE: If you extend the valueObject class, make sure to override the
* clone() method in it!
*/
public Board_ref createValueObject() {
return new Board_ref();
}
/**
* getObject-method. This will create and load valueObject contents from database
* using given Primary-Key as identifier. This method is just a convenience method
* for the real load-method which accepts the valueObject as a parameter. Returned
* valueObject will be created using the createValueObject() method.
*/
public Board_ref getObject(Connection conn, int ID_Board_Ref) throws NotFoundException, SQLException {
Board_ref valueObject = createValueObject();
valueObject.setID_Board_Ref(ID_Board_Ref);
load(conn, valueObject);
return valueObject;
}
/**
* load-method. This will load valueObject contents from database using
* Primary-Key as identifier. Upper layer should use this so that valueObject
* instance is created and only primary-key should be specified. Then call
* this method to complete other persistent information. This method will
* overwrite all other fields except primary-key and possible runtime variables.
* If load can not find matching row, NotFoundException will be thrown.
*
* @param conn This method requires working database connection.
* @param valueObject This parameter contains the class instance to be loaded.
* Primary-key field must be set for this to work properly.
*/
public void load(Connection conn, Board_ref valueObject) throws NotFoundException, SQLException {
String sql = "SELECT * FROM board_ref WHERE (ID_Board_Ref = ? ) ";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
stmt.setInt(1, valueObject.getID_Board_Ref());
singleQuery(conn, stmt, valueObject);
} finally {
if (stmt != null)
stmt.close();
}
}
/**
* LoadAll-method. This will read all contents from database table and
* build a List containing valueObjects. Please note, that this method
* will consume huge amounts of resources if table has lot's of rows.
* This should only be used when target tables have only small amounts
* of data.
*
* @param conn This method requires working database connection.
*/
public List loadAll(Connection conn) throws SQLException {
// Check the cache status and use Cache if possible.
if (cacheOk) {
return cacheData;
}
String sql = "SELECT * FROM board_ref ORDER BY ID_Board_Ref ASC ";
List searchResults = listQuery(conn, conn.prepareStatement(sql));
// Update cache and mark it ready.
cacheData = searchResults;
cacheOk = true;
return searchResults;
}
/**
* create-method. This will create new row in database according to supplied
* valueObject contents. Make sure that values for all NOT NULL columns are
* correctly specified. Also, if this table does not use automatic surrogate-keys
* the primary-key must be specified. After INSERT command this method will
* read the generated primary-key back to valueObject if automatic surrogate-keys
* were used.
*
* @param conn This method requires working database connection.
* @param valueObject This parameter contains the class instance to be created.
* If automatic surrogate-keys are not used the Primary-key
* field must be set for this to work properly.
*/
public synchronized void create(Connection conn, Board_ref valueObject) throws SQLException {
String sql = "";
PreparedStatement stmt = null;
ResultSet result = null;
// Connection conn = null;
// conn = ConnectDatabaseDAO.getInstance();
// création des objets DAO
//BoardclassDao boardclass_dao = new BoardclassDao ();
try {
sql = "INSERT INTO board_ref ( ID_Board_Ref, Board_Ref, Board_Ref_Name, "
+ "ID_Board_Class, Board_Slothoused, Board_Port_type1, "
+ "Board_Port_Type1_number, Board_Port_type2, Board_Port_Type2_number, "
+ "Board_Port_type3, Board_Port_Type3_number, NeededService_Board, "
+ "ID_Board_Slot_rule) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
stmt = conn.prepareStatement(sql);
// créer un board class
// if(valueObject.getBoard_Class().getID_BoardClass() == 0){
BoardclassDao boardclass_dao = new BoardclassDao ();
//DAO<Langage> langageDAO = AbstractDAOFactory .getFactory(FactoryType.DAO_FACTORY)
//.getLangageDAO();
// obj.setLangage(langageDAO.create(obj.getLangage()));
// boardclass_dao.create(conn, valueObject.getBoard_Class());
//valueObject.setBoard_Class(boardclass_dao.create(conn, valueObject.getBoard_Class()));
// }
//BoardclassDao boardclass_dao = new BoardclassDao ();
stmt.setInt(1, valueObject.getID_Board_Ref());
stmt.setString(2, valueObject.getBoard_Ref());
stmt.setString(3, valueObject.getBoard_Ref_Name());
// stmt.setInt(4, valueObject.getBoard_Class().getID_BoardClass());
// valueObject.setBoard_Class(boardclass_dao.create(conn, valueObject.getBoard_Class()));
// stmt.setBoard_Class(4, boardclass_dao.create(conn, valueObject.getBoard_Class()));
// stmt.setBoard_Class (4, valueObject.getBoard_Class());
stmt.setInt(4, valueObject.getBoard_Class().getID_BoardClass());
stmt.setInt(5, valueObject.getBoard_Slothoused());
stmt.setInt(6, valueObject.getBoard_Port_type1().getID_Port_Type());
stmt.setInt(7, valueObject.getBoard_Port_Type1_number());
stmt.setInt(8, valueObject.getBoard_Port_type2().getID_Port_Type());
stmt.setInt(9, valueObject.getBoard_Port_Type2_number());
stmt.setInt(10, valueObject.getBoard_Port_type3().getID_Port_Type());
stmt.setInt(11, valueObject.getBoard_Port_Type3_number());
stmt.setInt(12, valueObject.getNeededService_Board());
stmt.setInt(13, valueObject.getBoard_Slot_rule().getEng_Rule_Board_Valid_Slot_ID());
int rowcount = databaseUpdate(conn, stmt);
if (rowcount != 1) {
//System.out.println("PrimaryKey Error when updating DB!");
throw new SQLException("PrimaryKey Error when updating DB!");
}
} finally {
if (stmt != null)
stmt.close();
}
}
/**
* save-method. This method will save the current state of valueObject to database.
* Save can not be used to create new instances in database, so upper layer must
* make sure that the primary-key is correctly specified. Primary-key will indicate
* which instance is going to be updated in database. If save can not find matching
* row, NotFoundException will be thrown.
*
* @param conn This method requires working database connection.
* @param valueObject This parameter contains the class instance to be saved.
* Primary-key field must be set for this to work properly.
*/
public void save(Connection conn, Board_ref valueObject)
throws NotFoundException, SQLException {
String sql = "UPDATE board_ref SET Board_Ref = ?, Board_Ref_Name = ?, ID_Board_Class = ?, "
+ "Board_Slothoused = ?, Board_Port_type1 = ?, Board_Port_Type1_number = ?, "
+ "Board_Port_type2 = ?, Board_Port_Type2_number = ?, Board_Port_type3 = ?, "
+ "Board_Port_Type3_number = ?, NeededService_Board = ?, ID_Board_Slot_rule = ? WHERE (ID_Board_Ref = ? ) ";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
stmt.setString(1, valueObject.getBoard_Ref());
stmt.setString(2, valueObject.getBoard_Ref_Name());
stmt.setInt(3, valueObject.getBoard_Class().getID_BoardClass());
stmt.setInt(4, valueObject.getBoard_Slothoused());
stmt.setInt(5, valueObject.getBoard_Port_type1().getID_Port_Type());
stmt.setInt(6, valueObject.getBoard_Port_Type1_number());
stmt.setInt(7, valueObject.getBoard_Port_type2().getID_Port_Type());
stmt.setInt(8, valueObject.getBoard_Port_Type2_number());
stmt.setInt(9, valueObject.getBoard_Port_type3().getID_Port_Type());
stmt.setInt(10, valueObject.getBoard_Port_Type3_number());
stmt.setInt(11, valueObject.getNeededService_Board());
stmt.setInt(12, valueObject.getBoard_Slot_rule().getEng_Rule_Board_Valid_Slot_ID());
stmt.setInt(13, valueObject.getID_Board_Ref());
int rowcount = databaseUpdate(conn, stmt);
if (rowcount == 0) {
//System.out.println("Object could not be saved! (PrimaryKey not found)");
throw new NotFoundException("Object could not be saved! (PrimaryKey not found)");
}
if (rowcount > 1) {
//System.out.println("PrimaryKey Error when updating DB! (Many objects were affected!)");
throw new SQLException("PrimaryKey Error when updating DB! (Many objects were affected!)");
}
} finally {
if (stmt != null)
stmt.close();
}
}
/**
* delete-method. This method will remove the information from database as identified by
* by primary-key in supplied valueObject. Once valueObject has been deleted it can not
* be restored by calling save. Restoring can only be done using create method but if
* database is using automatic surrogate-keys, the resulting object will have different
* primary-key than what it was in the deleted object. If delete can not find matching row,
* NotFoundException will be thrown.
*
* @param conn This method requires working database connection.
* @param valueObject This parameter contains the class instance to be deleted.
* Primary-key field must be set for this to work properly.
*/
public void delete(Connection conn, Board_ref valueObject)
throws NotFoundException, SQLException {
String sql = "DELETE FROM board_ref WHERE (ID_Board_Ref = ? ) ";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
stmt.setInt(1, valueObject.getID_Board_Ref());
int rowcount = databaseUpdate(conn, stmt);
if (rowcount == 0) {
//System.out.println("Object could not be deleted (PrimaryKey not found)");
throw new NotFoundException("Object could not be deleted! (PrimaryKey not found)");
}
if (rowcount > 1) {
//System.out.println("PrimaryKey Error when updating DB! (Many objects were deleted!)");
throw new SQLException("PrimaryKey Error when updating DB! (Many objects were deleted!)");
}
} finally {
if (stmt != null)
stmt.close();
}
}
/**
* deleteAll-method. This method will remove all information from the table that matches
* this Dao and ValueObject couple. This should be the most efficient way to clear table.
* Once deleteAll has been called, no valueObject that has been created before can be
* restored by calling save. Restoring can only be done using create method but if database
* is using automatic surrogate-keys, the resulting object will have different primary-key
* than what it was in the deleted object. (Note, the implementation of this method should
* be different with different DB backends.)
*
* @param conn This method requires working database connection.
*/
public void deleteAll(Connection conn) throws SQLException {
String sql = "DELETE FROM board_ref";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
int rowcount = databaseUpdate(conn, stmt);
} finally {
if (stmt != null)
stmt.close();
}
}
/**
* coutAll-method. This method will return the number of all rows from table that matches
* this Dao. The implementation will simply execute "select count(primarykey) from table".
* If table is empty, the return value is 0. This method should be used before calling
* loadAll, to make sure table has not too many rows.
*
* @param conn This method requires working database connection.
*/
public int countAll(Connection conn) throws SQLException {
// Check the cache status and use Cache if possible.
if (cacheOk) {
return cacheData.size();
}
String sql = "SELECT count(*) FROM board_ref";
PreparedStatement stmt = null;
ResultSet result = null;
int allRows = 0;
try {
stmt = conn.prepareStatement(sql);
result = stmt.executeQuery();
if (result.next())
allRows = result.getInt(1);
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
return allRows;
}
/**
* searchMatching-Method. This method provides searching capability to
* get matching valueObjects from database. It works by searching all
* objects that match permanent instance variables of given object.
* Upper layer should use this by setting some parameters in valueObject
* and then call searchMatching. The result will be 0-N objects in a List,
* all matching those criteria you specified. Those instance-variables that
* have NULL values are excluded in search-criteria.
*
* @param conn This method requires working database connection.
* @param valueObject This parameter contains the class instance where search will be based.
* Primary-key field should not be set.
*/
public List searchMatching(Connection conn, Board_ref valueObject) throws SQLException {
List searchResults;
boolean first = true;
StringBuffer sql = new StringBuffer("SELECT * FROM board_ref WHERE 1=1 ");
if (valueObject.getID_Board_Ref() != 0) {
if (first) { first = false; }
sql.append("AND ID_Board_Ref = ").append(valueObject.getID_Board_Ref()).append(" ");
}
if (valueObject.getBoard_Ref() != null) {
if (first) { first = false; }
sql.append("AND Board_Ref LIKE '").append(valueObject.getBoard_Ref()).append("%' ");
}
if (valueObject.getBoard_Ref_Name() != null) {
if (first) { first = false; }
sql.append("AND Board_Ref_Name LIKE '").append(valueObject.getBoard_Ref_Name()).append("%' ");
}
if (valueObject.getBoard_Class().getID_BoardClass() != 0) {
if (first) { first = false; }
sql.append("AND ID_Board_Class = ").append(valueObject.getBoard_Class().getID_BoardClass()).append(" ");
}
if (valueObject.getBoard_Slothoused() != 0) {
if (first) { first = false; }
sql.append("AND Board_Slothoused = ").append(valueObject.getBoard_Slothoused()).append(" ");
}
if (valueObject.getBoard_Port_type1().getID_Port_Type() != 0) {
if (first) { first = false; }
sql.append("AND Board_Port_type1 = ").append(valueObject.getBoard_Port_type1().getID_Port_Type()).append(" ");
}
if (valueObject.getBoard_Port_Type1_number() != 0) {
if (first) { first = false; }
sql.append("AND Board_Port_Type1_number = ").append(valueObject.getBoard_Port_Type1_number()).append(" ");
}
if (valueObject.getBoard_Port_type2().getID_Port_Type() != 0) {
if (first) { first = false; }
sql.append("AND Board_Port_type2 = ").append(valueObject.getBoard_Port_type2().getID_Port_Type()).append(" ");
}
if (valueObject.getBoard_Port_Type2_number() != 0) {
if (first) { first = false; }
sql.append("AND Board_Port_Type2_number = ").append(valueObject.getBoard_Port_Type2_number()).append(" ");
}
if (valueObject.getBoard_Port_type3().getID_Port_Type() != 0) {
if (first) { first = false; }
sql.append("AND Board_Port_type3 = ").append(valueObject.getBoard_Port_type3().getID_Port_Type()).append(" ");
}
if (valueObject.getBoard_Port_Type3_number() != 0) {
if (first) { first = false; }
sql.append("AND Board_Port_Type3_number = ").append(valueObject.getBoard_Port_Type3_number()).append(" ");
}
if (valueObject.getNeededService_Board() != 0) {
if (first) { first = false; }
sql.append("AND NeededService_Board = ").append(valueObject.getNeededService_Board()).append(" ");
}
if (valueObject.getBoard_Slot_rule().getEng_Rule_Board_Valid_Slot_ID() != 0) {
if (first) { first = false; }
sql.append("AND ID_Board_Slot_rule = ").append(valueObject.getBoard_Slot_rule().getEng_Rule_Board_Valid_Slot_ID()).append(" ");
}
sql.append("ORDER BY ID_Board_Ref ASC ");
// Prevent accidential full table results.
// Use loadAll if all rows must be returned.
if (first)
searchResults = new ArrayList();
else
searchResults = listQuery(conn, conn.prepareStatement(sql.toString()));
return searchResults;
}
/**
* getDaogenVersion will return information about
* generator which created these sources.
*/
public String getDaogenVersion() {
return "DaoGen version 2.4.1";
}
/**
* databaseUpdate-method. This method is a helper method for internal use. It will execute
* all database handling that will change the information in tables. SELECT queries will
* not be executed here however. The return value indicates how many rows were affected.
* This method will also make sure that if cache is used, it will reset when data changes.
*
* @param conn This method requires working database connection.
* @param stmt This parameter contains the SQL statement to be excuted.
*/
protected int databaseUpdate(Connection conn, PreparedStatement stmt) throws SQLException {
int result = stmt.executeUpdate();
resetCache();
return result;
}
/**
* databaseQuery-method. This method is a helper method for internal use. It will execute
* all database queries that will return only one row. The resultset will be converted
* to valueObject. If no rows were found, NotFoundException will be thrown.
*
* @param conn This method requires working database connection.
* @param stmt This parameter contains the SQL statement to be excuted.
* @param valueObject Class-instance where resulting data will be stored.
*/
protected void singleQuery(Connection conn, PreparedStatement stmt, Board_ref valueObject)
throws NotFoundException, SQLException {
ResultSet result = null;
try {
result = stmt.executeQuery();
// à ajouter *************************************************************
BoardclassDao board_class_dao = new BoardclassDao();
Port_typeDao port_type_dao = new Port_typeDao () ;
Port_typeDao port_type_dao2 = new Port_typeDao () ;
Port_typeDao port_type_dao3 = new Port_typeDao () ;
Eng_rule_board_valid_slotDao eng_rule_board_valid_slot_dao = new Eng_rule_board_valid_slotDao();
Boardclass bc = new Boardclass () ;
Port_type pt1 = new Port_type () ;
Port_type pt2 = new Port_type () ;
Port_type pt3 = new Port_type () ;
Eng_rule_board_valid_slot valid_slot = new Eng_rule_board_valid_slot();
// fin de l'ajout *********************************************
// br = board_class_dao.getObject(conn, result.getInt("ID_Board_Class"));
if (result.next()) {
// à ajouter ******************************************************************************************
bc = board_class_dao.getObject(conn, result.getInt("ID_Board_Class"));
pt1 = port_type_dao.getObject(conn, result.getInt("Board_Port_type1"));
pt2 = port_type_dao2.getObject(conn, result.getInt("Board_Port_type2"));
pt3 = port_type_dao3.getObject(conn, result.getInt("Board_Port_type3"));
valid_slot = eng_rule_board_valid_slot_dao.getObject(conn, result.getInt("ID_Board_Slot_rule"));
// fin de l'ajout *************************************************************************************
valueObject.setID_Board_Ref(result.getInt("ID_Board_Ref"));
valueObject.setBoard_Ref(result.getString("Board_Ref"));
valueObject.setBoard_Ref_Name(result.getString("Board_Ref_Name"));
// valueObject.getBoard_Class().setID_BoardClass((result.getInt("ID_Board_Class")));
valueObject.getBoard_Class().setID_BoardClass(bc.getID_BoardClass());
// un point à suivre******************************************************************************
// ceci permet d'avoir 2 comme valeur pour boardclass_name
//valueObject.getBoard_Class().setBoardClass_Name(result.getString("ID_Board_Class"));
// ceci permet d'avoir null comme valeur pour boardclass
//valueObject.getBoard_Class().setBoardClass_Name(result.getInt("ID_Board_Class"));
// ceci ne fonctionne pas
//valueObject.getBoard_Class().setBoardClass_Name((getBoard_Class(result.getInt("ID_Board_Class")).getBoardClass_Name()));
//***********************************************************************************************
// ceci permet de mettre la valeur de setBoardClass_Name
valueObject.getBoard_Class().setBoardClass_Name(bc.getBoardClass_Name());
valueObject.setBoard_Slothoused(result.getInt("Board_Slothoused"));
// avec set all
// valueObject.getBoard_Class().setAll(bc.getID_BoardClass(), bc.getBoardClass_Name());
// valueObject.getBoard_Port_type1().setID_Port_Type((result.getInt("Board_Port_type1")));
// à ajouter *****************************************************
valueObject.getBoard_Port_type1().setID_Port_Type(pt1.getID_Port_Type());
valueObject.getBoard_Port_type1().setPort_Type_Name(pt1.getPort_Type_Name());
valueObject.getBoard_Port_type1().setPort_Type_capacity(pt1.getPort_Type_capacity());
// fin de l'ajout ************************************************
valueObject.setBoard_Port_Type1_number(result.getInt("Board_Port_Type1_number"));
// valueObject.getBoard_Port_type2().setID_Port_Type((result.getInt("Board_Port_type2")));
valueObject.getBoard_Port_type2().setID_Port_Type(pt2.getID_Port_Type());
valueObject.getBoard_Port_type2().setPort_Type_Name(pt2.getPort_Type_Name());
valueObject.getBoard_Port_type2().setPort_Type_capacity(pt2.getPort_Type_capacity());
valueObject.setBoard_Port_Type2_number(result.getInt("Board_Port_Type2_number"));
//valueObject.getBoard_Port_type3().setID_Port_Type((result.getInt("Board_Port_type3")));
valueObject.getBoard_Port_type3().setID_Port_Type(pt3.getID_Port_Type());
valueObject.getBoard_Port_type3().setPort_Type_Name(pt3.getPort_Type_Name());
valueObject.getBoard_Port_type3().setPort_Type_capacity(pt3.getPort_Type_capacity());
valueObject.setBoard_Port_Type3_number(result.getInt("Board_Port_Type3_number"));
valueObject.setNeededService_Board(result.getInt("NeededService_Board"));
//valueObject.getBoard_Slot_rule().setEng_Rule_Board_Valid_Slot_ID((result.getInt("ID_Board_Slot_rule")));
valueObject.getBoard_Slot_rule().setEng_Rule_Board_Valid_Slot_ID(valid_slot.getEng_Rule_Board_Valid_Slot_ID());
valueObject.getBoard_Slot_rule().setBoard_Ref(valid_slot.getBoard_Ref());
valueObject.getBoard_Slot_rule().setBoard_valid_slot_numbers(valid_slot.getBoard_valid_slot_numbers());
valueObject.getBoard_Slot_rule().setID_NeType(valid_slot.getID_NeType());
valueObject.getBoard_Slot_rule().setSlot_count(valid_slot.getSlot_count());
} else {
//System.out.println("Board_ref Object Not Found!");
throw new NotFoundException("Board_ref Object Not Found!");
}
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
}
/**
* databaseQuery-method. This method is a helper method for internal use. It will execute
* all database queries that will return multiple rows. The resultset will be converted
* to the List of valueObjects. If no rows were found, an empty List will be returned.
*
* @param conn This method requires working database connection.
* @param stmt This parameter contains the SQL statement to be excuted.
*/
protected List listQuery(Connection conn, PreparedStatement stmt) throws SQLException {
ArrayList searchResults = new ArrayList();
ResultSet result = null;
try {
result = stmt.executeQuery();
while (result.next()) {
Board_ref temp = createValueObject();
temp.setID_Board_Ref(result.getInt("ID_Board_Ref"));
temp.setBoard_Ref(result.getString("Board_Ref"));
temp.setBoard_Ref_Name(result.getString("Board_Ref_Name"));
temp.getBoard_Class().setID_BoardClass((result.getInt("ID_Board_Class")));
temp.setBoard_Slothoused(result.getInt("Board_Slothoused"));
temp.getBoard_Port_type1().setID_Port_Type((result.getInt("Board_Port_type1")));
temp.setBoard_Port_Type1_number(result.getInt("Board_Port_Type1_number"));
temp.getBoard_Port_type2().setID_Port_Type((result.getInt("Board_Port_type2")));
temp.setBoard_Port_Type2_number(result.getInt("Board_Port_Type2_number"));
temp.getBoard_Port_type3().setID_Port_Type((result.getInt("Board_Port_type3")));
temp.setBoard_Port_Type3_number(result.getInt("Board_Port_Type3_number"));
temp.setNeededService_Board(result.getInt("NeededService_Board"));
temp.getBoard_Slot_rule().setEng_Rule_Board_Valid_Slot_ID((result.getInt("ID_Board_Slot_rule")));
searchResults.add(temp);
}
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
return (List)searchResults;
}
} |