static { DATABASE_NAME = "track"; TABLE_NAME = "TOPTION"; OBJECTID = "TOPTION.OBJECTID"; LIST = "TOPTION.LIST"; LABEL = "TOPTION.LABEL"; TOOLTIP = "TOPTION.TOOLTIP"; PARENTOPTION = "TOPTION.PARENTOPTION"; SORTORDER = "TOPTION.SORTORDER"; ISDEFAULT = "TOPTION.ISDEFAULT"; DELETED = "TOPTION.DELETED"; SYMBOL = "TOPTION.SYMBOL"; ICONKEY = "TOPTION.ICONKEY"; ICONCHANGED = "TOPTION.ICONCHANGED"; CSSSTYLE = "TOPTION.CSSSTYLE"; TPUUID = "TOPTION.TPUUID"; if (Torque.isInit()) { try { Torque.getMapBuilder(TOptionMapBuilder.CLASS_NAME); } catch (TorqueException e) { log.error("Could not initialize Peer", e); throw new TorqueRuntimeException(e); } } else { Torque.registerMapBuilder(TOptionMapBuilder.CLASS_NAME); } }
/** * Constructor. Provided as long as both Constructors, IDBroker(DatabaseInfo) and * IDBroker(TableMap), are around. * * @param databaseName the name of the database for which this IdBroker provides Ids. */ private IDBroker(String databaseName) { this.databaseName = databaseName; configuration = Torque.getConfiguration(); // Start the housekeeper thread only if prefetch has not been disabled if (configuration.getBoolean(DB_IDBROKER_PREFETCH, true)) { houseKeeperThread = new Thread(this); // Indicate that this is a system thread. JVM will quit only when // there are no more active user threads. Settings threads spawned // internally by Torque as daemons allows commandline applications // using Torque terminate in an orderly manner. houseKeeperThread.setDaemon(true); houseKeeperThread.setName("Torque - ID Broker thread"); houseKeeperThread.start(); } // Check for Transaction support. Give warning message if // IDBroker is being used with a database that does not // support transactions. Connection dbCon = null; try { dbCon = Torque.getConnection(databaseName); } catch (Throwable t) { log.error("Could not open a connection to the database " + databaseName, t); transactionsSupported = false; } try { transactionsSupported = dbCon.getMetaData().supportsTransactions(); } catch (Exception e) { log.warn( "Could not read from connection Metadata" + " whether transactions are supported for the database " + databaseName, e); transactionsSupported = false; } finally { try { // Return the connection to the pool. dbCon.close(); } catch (Exception e) { log.warn( "Could not close the connection which was used " + "for testing whether transactions are supported", e); } } if (!transactionsSupported) { log.warn( "IDBroker is being used with db '" + databaseName + "', which does not support transactions. IDBroker " + "attempts to use transactions to limit the possibility " + "of duplicate key generation. Without transactions, " + "duplicate key generation is possible if multiple JVMs " + "are used or other means are used to write to the " + "database."); } }
/** * Retrieve a multiple objects by pk * * @param pks List of primary keys * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static List retrieveByPKs(List pks) throws TorqueException { Connection db = null; List retVal = null; try { db = Torque.getConnection(DATABASE_NAME); retVal = retrieveByPKs(pks, db); } finally { Torque.closeConnection(db); } return (retVal); }
/** * Retrieve a multiple objects by pk * * @param pks List of primary keys * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static List<TRoleListType> retrieveByPKs(List<ObjectKey> pks) throws TorqueException { Connection db = null; List<TRoleListType> retVal = null; try { db = Torque.getConnection(DATABASE_NAME); retVal = retrieveByPKs(pks, db); } finally { Torque.closeConnection(db); } return retVal; }
/** * Retrieve a single object by pk * * @param pk the primary key * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. * @throws NoRowsException Primary key was not found in database. * @throws TooManyRowsException Primary key was not found in database. */ public static Exam retrieveByPK(ObjectKey pk) throws TorqueException, NoRowsException, TooManyRowsException { Connection db = null; Exam retVal = null; try { db = Torque.getConnection(DATABASE_NAME); retVal = retrieveByPK(pk, db); } finally { Torque.closeConnection(db); } return (retVal); }
static { PRODUCT_CAT_ID = "PRODUCT_CATEGORY.PRODUCT_CAT_ID"; PRODUCT_CAT_NAME = "PRODUCT_CATEGORY.PRODUCT_CAT_NAME"; if (Torque.isInit()) { try { getMapBuilder(ProductCategoryMapBuilder.CLASS_NAME); } catch (Exception e) { log.error("Could not initialize Peer", e); } } else { Torque.registerMapBuilder(ProductCategoryMapBuilder.CLASS_NAME); } }
static { ID = "ATTENDENCE_SEET.ID"; USER_ID = "ATTENDENCE_SEET.USER_ID"; LOGIN_DATE = "ATTENDENCE_SEET.LOGIN_DATE"; IPADDRESS = "ATTENDENCE_SEET.IPADDRESS"; if (Torque.isInit()) { try { getMapBuilder(AttendenceSeetMapBuilder.CLASS_NAME); } catch (Exception e) { log.error("Could not initialize Peer", e); } } else { Torque.registerMapBuilder(AttendenceSeetMapBuilder.CLASS_NAME); } }
/** * @param tableName a <code>String</code> value that is used to identify the row * @return a <code>boolean</code> value * @exception TorqueException if a Torque error occurs. * @exception Exception if another error occurs. */ public boolean exists(String tableName) throws Exception { String query = new StringBuffer(100) .append("select ") .append(TABLE_NAME) .append(" where ") .append(TABLE_NAME) .append("='") .append(tableName) .append('\'') .toString(); boolean exists = false; Connection dbCon = null; try { dbCon = Torque.getConnection(databaseName); Statement statement = dbCon.createStatement(); ResultSet rs = statement.executeQuery(query); exists = rs.next(); statement.close(); } finally { // Return the connection to the pool. try { dbCon.close(); } catch (Exception e) { log.error("Release of connection failed.", e); } } return exists; }
// @Test public void testSelect() throws TorqueException, SQLException { Criteria crit = new Criteria(); crit.setDbName("eagle"); crit.addSelectColumn(new ColumnImpl("column1")); crit.addSelectColumn(new ColumnImpl("column2")); crit.addSelectColumn(new ColumnImpl("column2/100")); crit.where(new ColumnImpl("column1"), SqlEnum.GREATER_EQUAL); crit.addFrom("tableName"); crit.addAlias("column1", "c1"); crit.addGroupByColumn(new ColumnImpl("column1")); crit.addAscendingOrderByColumn(new ColumnImpl("column3")); crit.setLimit(1000); Query query = SqlBuilder.buildQuery(crit); String sql = query.toString(); System.out.println(sql); Connection connection = Torque.getConnection(); PreparedStatement statement = connection.prepareStatement(sql); statement.setInt(1, 1000); try { ResultSet result = statement.executeQuery(); } catch (SQLException ex) { LOG.warn(ex.getMessage(), ex); } finally { connection.close(); } }
static { EXAM_ID = "exam.EXAM_ID"; TITLE = "exam.TITLE"; TIME_OF_EXAM = "exam.TIME_OF_EXAM"; UPLOADED_BY = "exam.UPLOADED_BY"; DATE_UPLOADED = "exam.DATE_UPLOADED"; INSTRUCTIONS = "exam.INSTRUCTIONS"; if (Torque.isInit()) { try { getMapBuilder(ExamMapBuilder.CLASS_NAME); } catch (Exception e) { log.error("Could not initialize Peer", e); } } else { Torque.registerMapBuilder(ExamMapBuilder.CLASS_NAME); } }
private static void setDbName(Criteria crit) { // Set the correct dbName if it has not been overridden // crit.getDbName will return the same object if not set to // another value so == check is okay and faster if (crit.getDbName() == Torque.getDefaultDB()) { crit.setDbName(DATABASE_NAME); } }
static { DATABASE_NAME = "track"; TABLE_NAME = "TROLELISTTYPE"; OBJECTID = "TROLELISTTYPE.OBJECTID"; PROLE = "TROLELISTTYPE.PROLE"; LISTTYPE = "TROLELISTTYPE.LISTTYPE"; TPUUID = "TROLELISTTYPE.TPUUID"; if (Torque.isInit()) { try { Torque.getMapBuilder(TRoleListTypeMapBuilder.CLASS_NAME); } catch (TorqueException e) { log.error("Could not initialize Peer", e); throw new TorqueRuntimeException(e); } } else { Torque.registerMapBuilder(TRoleListTypeMapBuilder.CLASS_NAME); } }
static { DATABASE_NAME = "track"; TABLE_NAME = "TDOMAIN"; OBJECTID = "TDOMAIN.OBJECTID"; LABEL = "TDOMAIN.LABEL"; DESCRIPTION = "TDOMAIN.DESCRIPTION"; TPUUID = "TDOMAIN.TPUUID"; if (Torque.isInit()) { try { Torque.getMapBuilder(TDomainMapBuilder.CLASS_NAME); } catch (TorqueException e) { log.error("Could not initialize Peer", e); throw new TorqueRuntimeException(e); } } else { Torque.registerMapBuilder(TDomainMapBuilder.CLASS_NAME); } }
static { LOG_ID = "system_log.LOG_ID"; USER_ID = "system_log.USER_ID"; ACTION = "system_log.ACTION"; LOCATION = "system_log.LOCATION"; PREVIOUS_VALUE = "system_log.PREVIOUS_VALUE"; CURRENT_VALUE = "system_log.CURRENT_VALUE"; NOTES = "system_log.NOTES"; DATE = "system_log.DATE"; if (Torque.isInit()) { try { getMapBuilder(System_LogMapBuilder.CLASS_NAME); } catch (Exception e) { log.error("Could not initialize Peer", e); } } else { Torque.registerMapBuilder(System_LogMapBuilder.CLASS_NAME); } }
static { ID = "Ordenes_Trabajo.ID"; FECHA_ENTRADA = "Ordenes_Trabajo.FECHA_ENTRADA"; FECHA_SALIDA = "Ordenes_Trabajo.FECHA_SALIDA"; OBSERVACION = "Ordenes_Trabajo.OBSERVACION"; REPARACION_ID = "Ordenes_Trabajo.REPARACION_ID"; IMPORTE = "Ordenes_Trabajo.IMPORTE"; TIPO = "Ordenes_Trabajo.TIPO"; RESPONSABLE_ID = "Ordenes_Trabajo.RESPONSABLE_ID"; HORAS = "Ordenes_Trabajo.HORAS"; DESCRIPCION = "Ordenes_Trabajo.DESCRIPCION"; if (Torque.isInit()) { try { getMapBuilder(OrdenTrabajoMapBuilder.CLASS_NAME); } catch (Exception e) { log.error("Could not initialize Peer", e); } } else { Torque.registerMapBuilder(OrdenTrabajoMapBuilder.CLASS_NAME); } }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap("brihaspati"); dbMap.addTable("DB_RECEIVE"); TableMap tMap = dbMap.getTable("DB_RECEIVE"); tMap.setPrimaryKeyMethod("none"); tMap.addPrimaryKey("DB_RECEIVE.MSG_ID", new Integer(0)); tMap.addPrimaryKey("DB_RECEIVE.RECEIVER_ID", new Integer(0)); tMap.addColumn("DB_RECEIVE.GROUP_ID", new Integer(0)); tMap.addColumn("DB_RECEIVE.READ_FLAG", new Integer(0)); }
static { DATABASE_NAME = "query_parse"; TABLE_NAME = "trie_words_suggest"; ID = "trie_words_suggest.id"; FK_KEYWORD_ID = "trie_words_suggest.fk_keyword_id"; SUGGEST_WORD = "trie_words_suggest.suggest_word"; SORT = "trie_words_suggest.sort"; VIEW_URL = "trie_words_suggest.view_url"; UPDATE_TIME = "trie_words_suggest.update_time"; CREATE_TIME = "trie_words_suggest.create_time"; if (Torque.isInit()) { try { Torque.getMapBuilder(TrieWordsSuggestMapBuilder.CLASS_NAME); } catch (TorqueException e) { log.error("Could not initialize Peer", e); throw new RuntimeException(e); } } else { Torque.registerMapBuilder(TrieWordsSuggestMapBuilder.CLASS_NAME); } }
static { DATABASE_NAME = "track"; TABLE_NAME = "TSCREENTAB"; OBJECTID = "TSCREENTAB.OBJECTID"; NAME = "TSCREENTAB.NAME"; LABEL = "TSCREENTAB.LABEL"; DESCRIPTION = "TSCREENTAB.DESCRIPTION"; SORTORDER = "TSCREENTAB.SORTORDER"; PARENT = "TSCREENTAB.PARENT"; TPUUID = "TSCREENTAB.TPUUID"; if (Torque.isInit()) { try { Torque.getMapBuilder(TScreenTabMapBuilder.CLASS_NAME); } catch (TorqueException e) { log.error("Could not initialize Peer", e); throw new TorqueRuntimeException(e); } } else { Torque.registerMapBuilder(TScreenTabMapBuilder.CLASS_NAME); } }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap("dream"); dbMap.addTable("DISTRIBUTOR"); TableMap tMap = dbMap.getTable("DISTRIBUTOR"); tMap.setPrimaryKeyMethod(TableMap.NATIVE); tMap.setPrimaryKeyMethodInfo("DISTRIBUTOR_SEQ"); tMap.addPrimaryKey("DISTRIBUTOR.DISTRIBUTOR_ID", new Integer(0)); tMap.addColumn("DISTRIBUTOR.DISTRIBUTOR_CODE", new String()); tMap.addColumn("DISTRIBUTOR.STATUS", new Integer(0)); tMap.addColumn("DISTRIBUTOR.DISTRIBUTOR_NAME_1", new String()); tMap.addColumn("DISTRIBUTOR.DISTRIBUTOR_NAME_2", new String()); tMap.addColumn("DISTRIBUTOR.DISTRIBUTOR_DISPLAY", new String()); tMap.addColumn("DISTRIBUTOR.DEAR", new String()); tMap.addColumn("DISTRIBUTOR.DISTRIBUTOR_TYPE", new Integer(0)); tMap.addColumn("DISTRIBUTOR.GENDER", new Integer(0)); tMap.addForeignKey( "DISTRIBUTOR.DISTRIBUTOR_CAT_ID", new Integer(0), "DISTRIBUTOR_CATEGORY", "DISTRIBUTOR_CAT_ID"); tMap.addForeignKey("DISTRIBUTOR.LANGUAGE_ID", new Integer(0), "LANGUAGE", "LANGUAGE_ID"); tMap.addColumn("DISTRIBUTOR.ADDRESS_1", new String()); tMap.addColumn("DISTRIBUTOR.ADDRESS_2", new String()); tMap.addColumn("DISTRIBUTOR.CITY", new String()); tMap.addColumn("DISTRIBUTOR.ZIP", new String()); tMap.addColumn("DISTRIBUTOR.STATE", new String()); tMap.addForeignKey("DISTRIBUTOR.COUNTRY_ID", new Integer(0), "COUNTRY", "COUNTRY_ID"); tMap.addForeignKey("DISTRIBUTOR.REGION_ID", new Integer(0), "REGION", "REGION_ID"); tMap.addColumn("DISTRIBUTOR.PHONE_1", new String()); tMap.addColumn("DISTRIBUTOR.PHONE_2", new String()); tMap.addColumn("DISTRIBUTOR.FAX", new String()); tMap.addColumn("DISTRIBUTOR.EMAIL", new String()); tMap.addColumn("DISTRIBUTOR.EMAIL_FORMAT", new Integer(0)); tMap.addColumn("DISTRIBUTOR.SEND_NEWS", new Integer(0)); tMap.addColumn("DISTRIBUTOR.WEB_URL", new String()); tMap.addColumn("DISTRIBUTOR.CUSTOM_1", new String()); tMap.addColumn("DISTRIBUTOR.CUSTOM_2", new String()); tMap.addColumn("DISTRIBUTOR.CUSTOM_3", new String()); tMap.addColumn("DISTRIBUTOR.CUSTOM_4", new String()); tMap.addColumn("DISTRIBUTOR.CUSTOM_5", new String()); tMap.addColumn("DISTRIBUTOR.CUSTOM_6", new String()); tMap.addColumn("DISTRIBUTOR.NOTES", new String()); tMap.addColumn("DISTRIBUTOR.CREATED", new Date()); tMap.addColumn("DISTRIBUTOR.MODIFIED", new Date()); tMap.addColumn("DISTRIBUTOR.CREATED_BY", new String()); tMap.addColumn("DISTRIBUTOR.MODIFIED_BY", new String()); }
/** * Method to do deletes. This method is to be used during a transaction, otherwise use the * doDelete(Criteria) method. It will take care of the connection details internally. * * @param criteria object containing data that is used DELETE from database. * @param con the connection to use * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static void doDelete(Criteria criteria, Connection con) throws TorqueException { // Set the correct dbName if it has not been overridden // criteria.getDbName will return the same object if not set to // another value so == check is okay and faster if (criteria.getDbName() == Torque.getDefaultDB()) { criteria.setDbName(DATABASE_NAME); } if (con == null) { BasePeer.doDelete(criteria); } else { BasePeer.doDelete(criteria, con); } }
static { DATABASE_NAME = "searchconsole"; TABLE_NAME = "user"; ID = "user.id"; NAME = "user.name"; PASSWORD = "******"; TRUE_NAME = "user.true_name"; TEAM = "user.team"; SEX = "user.sex"; BIRTH = "user.birth"; LASTLOGINDATE = "user.lastLoginDate"; if (Torque.isInit()) { try { getMapBuilder(UserMapBuilder.CLASS_NAME); } catch (Exception e) { log.error("Could not initialize Peer", e); throw new RuntimeException(e); } } else { Torque.registerMapBuilder(UserMapBuilder.CLASS_NAME); } }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap("brihaspati"); dbMap.addTable("USER_CONFIGURATION"); TableMap tMap = dbMap.getTable("USER_CONFIGURATION"); tMap.setPrimaryKeyMethod("none"); tMap.addPrimaryKey("USER_CONFIGURATION.USER_ID", new Integer(0)); tMap.addColumn("USER_CONFIGURATION.QUESTION_ID", new Integer(0)); tMap.addColumn("USER_CONFIGURATION.ANSWER", new String()); tMap.addColumn("USER_CONFIGURATION.LIST_CONFIGURATION", new Integer(0)); tMap.addColumn("USER_CONFIGURATION.PHOTO", new String()); tMap.addColumn("USER_CONFIGURATION.TASK_CONFIGURATION", new Integer(0)); }
// @Before public void setUp() throws TorqueException { Configuration configuration = new BaseConfiguration(); configuration.addProperty("torque.database.default", "eagle"); configuration.addProperty("torque.database.eagle.adapter", "mysql"); configuration.addProperty( "torque.dsfactory.eagle.factory", "org.apache.torque.dsfactory.SharedPoolDataSourceFactory"); configuration.addProperty( "torque.dsfactory.eagle.connection.driver", "org.gjt.mm.mysql.Driver"); configuration.addProperty( "torque.dsfactory.eagle.connection.url", "jdbc:mysql://localhost:3306/eagle"); configuration.addProperty("torque.dsfactory.eagle.connection.user", "eagle"); configuration.addProperty("torque.dsfactory.eagle.connection.password", "eagle"); Torque.init(configuration); }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public synchronized void doBuild() throws TorqueException { if (isBuilt()) { return; } dbMap = Torque.getDatabaseMap("mydb"); dbMap.addTable("tbl1"); TableMap tMap = dbMap.getTable("tbl1"); tMap.setJavaName("Tbl1"); tMap.setOMClass(org.grajagan.Tbl1.class); tMap.setPeerClass(org.grajagan.Tbl1Peer.class); tMap.setPrimaryKeyMethod(TableMap.NATIVE); tMap.setPrimaryKeyMethodInfo("tbl1"); ColumnMap cMap = null; // ------------- Column: tbl1_id -------------------- cMap = new ColumnMap("tbl1_id", tMap); cMap.setType(new Integer(0)); cMap.setTorqueType("INTEGER"); cMap.setUsePrimitive(true); cMap.setPrimaryKey(true); cMap.setNotNull(true); cMap.setJavaName("Tbl1Id"); cMap.setAutoIncrement(true); cMap.setProtected(false); cMap.setInheritance("false"); cMap.setPosition(1); tMap.addColumn(cMap); // ------------- Column: name -------------------- cMap = new ColumnMap("name", tMap); cMap.setType(""); cMap.setTorqueType("VARCHAR"); cMap.setUsePrimitive(true); cMap.setPrimaryKey(false); cMap.setNotNull(true); cMap.setJavaName("Name"); cMap.setAutoIncrement(false); cMap.setProtected(false); cMap.setInheritance("false"); cMap.setSize(64); cMap.setPosition(2); tMap.addColumn(cMap); tMap.setUseInheritance(false); }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap("default"); dbMap.addTable("JETSPEED_USER_PROFILE"); TableMap tMap = dbMap.getTable("JETSPEED_USER_PROFILE"); tMap.setPrimaryKeyMethod(TableMap.NATIVE); tMap.setPrimaryKeyMethodInfo("JETSPEED_USER_PROFILE"); tMap.addPrimaryKey("JETSPEED_USER_PROFILE.PSML_ID", new Integer(0)); tMap.addColumn("JETSPEED_USER_PROFILE.USER_NAME", new String()); tMap.addColumn("JETSPEED_USER_PROFILE.MEDIA_TYPE", new String()); tMap.addColumn("JETSPEED_USER_PROFILE.LANGUAGE", new String()); tMap.addColumn("JETSPEED_USER_PROFILE.COUNTRY", new String()); tMap.addColumn("JETSPEED_USER_PROFILE.PAGE", new String()); tMap.addColumn("JETSPEED_USER_PROFILE.PROFILE", new Object()); }
/** * selects a collection of System_Log objects pre-filled with their User objects. * * <p>This method is protected by default in order to keep the public api reasonable. You can * provide public methods for those you actually need in System_LogPeer. * * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ protected static List doSelectJoinUser(Criteria c) throws TorqueException { // Set the correct dbName if it has not been overridden // c.getDbName will return the same object if not set to // another value so == check is okay and faster if (c.getDbName() == Torque.getDefaultDB()) { c.setDbName(DATABASE_NAME); } System_LogPeer.addSelectColumns(c); int offset = numColumns + 1; UserPeer.addSelectColumns(c); c.addJoin(System_LogPeer.USER_ID, UserPeer.USER_ID); List rows = BasePeer.doSelect(c); List results = new ArrayList(); for (int i = 0; i < rows.size(); i++) { Record row = (Record) rows.get(i); Class omClass = System_LogPeer.getOMClass(); System_Log obj1 = (System_Log) System_LogPeer.row2Object(row, 1, omClass); omClass = UserPeer.getOMClass(); User obj2 = (User) UserPeer.row2Object(row, offset, omClass); boolean newObject = true; for (int j = 0; j < results.size(); j++) { System_Log temp_obj1 = (System_Log) results.get(j); User temp_obj2 = (User) temp_obj1.getUser(); if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) { newObject = false; temp_obj2.addSystem_Log(obj1); break; } } if (newObject) { obj2.initSystem_Logs(); obj2.addSystem_Log(obj1); } results.add(obj1); } return results; }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap("inventorysystemdb"); dbMap.addTable("user"); TableMap tMap = dbMap.getTable("user"); tMap.setPrimaryKeyMethod(TableMap.NATIVE); tMap.addPrimaryKey("user.USER_ID", new Integer(0)); tMap.addColumn("user.EMPLOYEENUMBER", new String()); tMap.addColumn("user.FIRSTNAME", new String()); tMap.addColumn("user.MIDDLENAME", new String()); tMap.addColumn("user.LASTNAME", new String()); tMap.addColumn("user.USERNAME", new String()); tMap.addColumn("user.PASSWORD", new String()); tMap.addPrimaryKey("user.CONTACTNUMBER", new String()); tMap.addColumn("user.DIVISION", new String()); tMap.addColumn("user.TYPE", new String()); tMap.addColumn("user.STATUS", new Integer(0)); }
/** * Grabs the raw Village records to be formed into objects. This method should be used for * transactions * * @param con the connection to use * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static List doSelectVillageRecords(Criteria criteria, Connection con) throws TorqueException { if (criteria.getSelectColumns().size() == 0) { addSelectColumns(criteria); } // Set the correct dbName if it has not been overridden // criteria.getDbName will return the same object if not set to // another value so == check is okay and faster if (criteria.getDbName() == Torque.getDefaultDB()) { criteria.setDbName(DATABASE_NAME); } // BasePeer returns a List of Value (Village) arrays. The array // order follows the order columns were placed in the Select clause. if (con == null) { return BasePeer.doSelect(criteria); } else { return BasePeer.doSelect(criteria, con); } }
/** * The doBuild() method builds the DatabaseMap * * @throws TorqueException */ public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap("brihaspati"); dbMap.addTable("TURBINE_USER"); TableMap tMap = dbMap.getTable("TURBINE_USER"); tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); tMap.setPrimaryKeyMethodInfo(tMap.getName()); tMap.addPrimaryKey("TURBINE_USER.USER_ID", new Integer(0)); tMap.addColumn("TURBINE_USER.LOGIN_NAME", new String()); tMap.addColumn("TURBINE_USER.PASSWORD_VALUE", new String()); tMap.addColumn("TURBINE_USER.FIRST_NAME", new String()); tMap.addColumn("TURBINE_USER.LAST_NAME", new String()); tMap.addColumn("TURBINE_USER.EMAIL", new String()); tMap.addColumn("TURBINE_USER.CONFIRM_VALUE", new String()); tMap.addColumn("TURBINE_USER.MODIFIED", new Date()); tMap.addColumn("TURBINE_USER.CREATED", new Date()); tMap.addColumn("TURBINE_USER.LAST_LOGIN", new Date()); tMap.addColumn("TURBINE_USER.OBJECTDATA", new Object()); tMap.addColumn("TURBINE_USER.QUOTA", new BigDecimal(0)); }
/** * This method allows you to get the number of ids that are to be cached in memory. This is either * stored in quantityStore or read from the db. (ie the value in ID_TABLE.QUANTITY). Though this * method returns a BigDecimal for the quantity, it is unlikey the system could withstand whatever * conditions would lead to really needing a large quantity, it is retrieved as a BigDecimal only * because it is going to be added to another BigDecimal. * * @param tableName The name of the table we want to query. * @param connection a Connection * @return An int with the number of ids cached in memory. */ private BigDecimal getQuantity(String tableName, Connection connection) { BigDecimal quantity = null; // If prefetch is turned off we simply return 1 if (!configuration.getBoolean(DB_IDBROKER_PREFETCH, true)) { quantity = new BigDecimal((double) 1); } // Initialize quantity, if necessary. else if (quantityStore.containsKey(tableName)) { quantity = (BigDecimal) quantityStore.get(tableName); } else { Connection dbCon = null; try { if (connection == null || configuration.getBoolean(DB_IDBROKER_USENEWCONNECTION, true)) { // Get a connection to the db dbCon = Torque.getConnection(databaseName); } // Read the row from the ID_TABLE. BigDecimal[] results = selectRow(dbCon, tableName); // QUANTITY column. quantity = results[1]; quantityStore.put(tableName, quantity); } catch (Exception e) { quantity = new BigDecimal((double) 10); } finally { // Return the connection to the pool. try { dbCon.close(); } catch (Exception e) { log.error("Release of connection failed.", e); } } } return quantity; }