BaseJobEntryTorquePeerImpl.java
package org.apache.turbine.services.schedule;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.torque.NoRowsException;
import org.apache.torque.TooManyRowsException;
import org.apache.torque.TorqueException;
import org.apache.torque.criteria.Criteria;
import org.apache.torque.om.mapper.RecordMapper;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.map.TableMap;
import org.apache.torque.util.TorqueConnection;
import org.apache.torque.util.Transaction;
import org.apache.torque.util.ColumnValues;
import org.apache.torque.util.JdbcTypedValue;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Tue Jun 17 14:08:22 CEST 2025]
*
* You should not use this class directly. It should not even be
* extended; all references should be to JobEntryTorquePeer
*/
@SuppressWarnings("unused")
public abstract class BaseJobEntryTorquePeerImpl
extends org.apache.torque.util.AbstractPeerImpl<JobEntryTorque>
{
/** Serial version */
private static final long serialVersionUID = 1750162102041L;
/**
* Constructor.
* The recordMapper, tableMap and databaseName fields are correctly
* initialized.
*/
public BaseJobEntryTorquePeerImpl()
{
this(new JobEntryTorqueRecordMapper(),
JobEntryTorquePeer.TABLE,
JobEntryTorquePeer.DATABASE_NAME);
}
/**
* Constructor providing the objects to be injected as parameters.
*
* @param recordMapper a record mapper to map JDBC result sets to objects
* @param tableMap the default table map
* @param databaseName the name of the database
*/
public BaseJobEntryTorquePeerImpl(
RecordMapper<JobEntryTorque> recordMapper,
TableMap tableMap,
String databaseName)
{
super(recordMapper, tableMap, databaseName);
}
/**
* Returns a new instance of the Data object class
*/
public JobEntryTorque getDbObjectInstance()
{
return new JobEntryTorque();
}
/**
* Method to do updates. This method is to be used during a transaction,
* otherwise use the doUpdate(Criteria) method.
*
* @param columnValues the values to update plus the primary key
* identifying the row to update.
* @param con the connection to use, not null.
*
* @return the number of affected rows.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public int doUpdate(ColumnValues columnValues, Connection con)
throws TorqueException
{
Criteria selectCriteria = new Criteria(getDatabaseName());
correctBooleans(columnValues);
{
JdbcTypedValue pkValue
= columnValues.remove(JobEntryTorquePeer.JOB_ID);
if (pkValue == null)
{
throw new TorqueException(
"The value for the primary key column "
+ "JobEntryTorquePeer.JOB_ID"
+ " must be set");
}
if (pkValue.getSqlExpression() == null)
{
selectCriteria.where(
JobEntryTorquePeer.JOB_ID,
pkValue.getValue());
}
else
{
selectCriteria.where(
JobEntryTorquePeer.JOB_ID,
pkValue.getSqlExpression());
}
}
int rowCount = doUpdate(selectCriteria, columnValues, con);
return rowCount;
}
/**
* Deletes a data object, i.e. a row in a table, in the database.
*
* @param obj the data object to delete in the database, not null.
*
* @return the number of deleted rows.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public int doDelete(JobEntryTorque obj) throws TorqueException
{
int result = doDelete(buildCriteria(obj.getPrimaryKey()));
obj.setDeleted(true);
return result;
}
/**
* Deletes a data object, i.e. a row in a table, in the database.
* This method is to be used during a transaction, otherwise use the
* doDelete(JobEntryTorque) method.
*
* @param obj the data object to delete in the database, not null.
* @param con the connection to use, not null.
*
* @return the number of deleted rows.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public int doDelete(JobEntryTorque obj, Connection con)
throws TorqueException
{
int result = doDelete(buildCriteria(obj.getPrimaryKey()), con);
obj.setDeleted(true);
return result;
}
/**
* Deletes data objects, i.e. rows in a table, in the database.
*
* @param objects the data object to delete in the database, not null,
* may not contain null.
*
* @return the number of deleted rows.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public int doDelete(Collection<JobEntryTorque> objects)
throws TorqueException
{
int result = doDelete(buildPkCriteria(objects));
objects.forEach(object -> object.setDeleted(true));
return result;
}
/**
* Deletes data objects, i.e. rows in a table, in the database.
* This method uses the passed connection to delete the rows;
* if a transaction is open in the connection, the deletion happens inside
* this transaction.
*
* @param objects the data objects to delete in the database, not null,
* may not contain null.
* @param con the connection to use for deleting, not null.
*
* @return the number of deleted rows.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public int doDelete(
Collection<JobEntryTorque> objects,
Connection con)
throws TorqueException
{
int result = doDelete(buildPkCriteria(objects), con);
objects.forEach(object -> object.setDeleted(true));
return result;
}
/**
* Build a Criteria object which selects all objects which have a given
* primary key.
*
* @param pk the primary key value to build the criteria from, not null.
*/
public Criteria buildCriteria(ObjectKey<?> pk)
{
Criteria criteria = new Criteria();
criteria.and(JobEntryTorquePeer.JOB_ID, pk);
return criteria;
}
/**
* Build a Criteria object which selects all objects which primary keys
* are contained in the passed collection.
*
* @param pks the primary key values to build the criteria from, not null,
* may not contain null.
*/
public Criteria buildCriteria(Collection<ObjectKey<?>> pks)
{
Criteria criteria = new Criteria();
criteria.andIn(JobEntryTorquePeer.JOB_ID, pks);
return criteria;
}
/**
* Build a Criteria object which selects all passed objects using their
* primary key. Objects which do not yet have a primary key are ignored.
*
* @param objects the objects to build the criteria from, not null,
* may not contain null.
*/
public Criteria buildPkCriteria(
Collection<JobEntryTorque> objects)
{
return buildCriteria(objects.stream()
.map(object -> object.getPrimaryKey())
.collect(Collectors.toList()));
}
/**
* Build a Criteria object from the data object for this peer.
* The primary key columns are only added if the object is not new.
*
* @param obj the object to build the criteria from, not null.
*/
public Criteria buildCriteria(JobEntryTorque obj)
{
Criteria criteria = new Criteria(getDatabaseName());
if (!obj.isNew())
{
criteria.and(JobEntryTorquePeer.JOB_ID, obj.getJobId());
}
criteria.and(JobEntryTorquePeer.SECOND, obj.getSecond());
criteria.and(JobEntryTorquePeer.MINUTE, obj.getMinute());
criteria.and(JobEntryTorquePeer.HOUR, obj.getHour());
criteria.and(JobEntryTorquePeer.WEEK_DAY, obj.getWeekDay());
criteria.and(JobEntryTorquePeer.DAY_OF_MONTH, obj.getDayOfMonth());
criteria.and(JobEntryTorquePeer.TASK, obj.getTask());
criteria.and(JobEntryTorquePeer.EMAIL, obj.getEmail());
criteria.and(JobEntryTorquePeer.PROPERTY, obj.getProperty());
return criteria;
}
/**
* Build a Criteria object from the data object for this peer,
* skipping all binary columns.
*
* @param obj the object to build the criteria from, not null.
*/
public Criteria buildSelectCriteria(JobEntryTorque obj)
{
Criteria criteria = new Criteria(getDatabaseName());
if (!obj.isNew())
{
criteria.and(JobEntryTorquePeer.JOB_ID, obj.getJobId());
}
criteria.and(JobEntryTorquePeer.SECOND, obj.getSecond());
criteria.and(JobEntryTorquePeer.MINUTE, obj.getMinute());
criteria.and(JobEntryTorquePeer.HOUR, obj.getHour());
criteria.and(JobEntryTorquePeer.WEEK_DAY, obj.getWeekDay());
criteria.and(JobEntryTorquePeer.DAY_OF_MONTH, obj.getDayOfMonth());
criteria.and(JobEntryTorquePeer.TASK, obj.getTask());
criteria.and(JobEntryTorquePeer.EMAIL, obj.getEmail());
return criteria;
}
/**
* Returns the contents of the object as ColumnValues object.
* Primary key columns which are generated on insertion are not
* added to the returned object if they still have their initial
* value. Also, columns which have the useDatabaseDefaultValue
* flag set to true are also not added to the returned object
* if they still have their initial value.
*
* @throws TorqueException if the table map cannot be retrieved
* (should not happen).
*/
public ColumnValues buildColumnValues(JobEntryTorque jobEntryTorque)
throws TorqueException
{
ColumnValues columnValues = new ColumnValues();
if (!jobEntryTorque.isNew()
|| jobEntryTorque.getJobId() != 0)
{
columnValues.put(
JobEntryTorquePeer.JOB_ID,
new JdbcTypedValue(
jobEntryTorque.getJobId(),
4));
}
columnValues.put(
JobEntryTorquePeer.SECOND,
new JdbcTypedValue(
jobEntryTorque.getSecond(),
4));
columnValues.put(
JobEntryTorquePeer.MINUTE,
new JdbcTypedValue(
jobEntryTorque.getMinute(),
4));
columnValues.put(
JobEntryTorquePeer.HOUR,
new JdbcTypedValue(
jobEntryTorque.getHour(),
4));
columnValues.put(
JobEntryTorquePeer.WEEK_DAY,
new JdbcTypedValue(
jobEntryTorque.getWeekDay(),
4));
columnValues.put(
JobEntryTorquePeer.DAY_OF_MONTH,
new JdbcTypedValue(
jobEntryTorque.getDayOfMonth(),
4));
columnValues.put(
JobEntryTorquePeer.TASK,
new JdbcTypedValue(
jobEntryTorque.getTask(),
12));
columnValues.put(
JobEntryTorquePeer.EMAIL,
new JdbcTypedValue(
jobEntryTorque.getEmail(),
12));
columnValues.put(
JobEntryTorquePeer.PROPERTY,
new JdbcTypedValue(
jobEntryTorque.getProperty(),
-3));
return columnValues;
}
/**
* 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 JobEntryTorque retrieveByPK(int pk)
throws TorqueException, NoRowsException, TooManyRowsException
{
return retrieveByPK(SimpleKey.keyFor(pk));
}
/**
* Retrieve a single object by pk
*
* @param pk the primary key
* @param con the connection to use
* @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 JobEntryTorque retrieveByPK(int pk, Connection con)
throws TorqueException, NoRowsException, TooManyRowsException
{
return retrieveByPK(SimpleKey.keyFor(pk), con);
}
/**
* 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 JobEntryTorque retrieveByPK(ObjectKey<?> pk)
throws TorqueException, NoRowsException, TooManyRowsException
{
try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
{
JobEntryTorque result = retrieveByPK(pk, connection);
Transaction.commit(connection);
return result;
}
}
/**
* Retrieve a single object by pk
*
* @param pk the primary key
* @param con the connection to use
* @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 JobEntryTorque retrieveByPK(ObjectKey<?> pk, Connection con)
throws TorqueException, NoRowsException, TooManyRowsException
{
Criteria criteria = buildCriteria(pk);
JobEntryTorque v = doSelectSingleRecord(criteria, con);
if (v == null)
{
throw new NoRowsException("Failed to select a row.");
}
return v;
}
/**
* Retrieve multiple objects by pk.
*
* @param pks List of primary keys.
* Entries in pks which do not match entries in the database are ignored.
*
* @return the list of matching objects, not null.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public List<JobEntryTorque> retrieveByTypedPKs(Collection<Integer> pks)
throws TorqueException
{
try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
{
List<JobEntryTorque> result = retrieveByTypedPKs(pks, connection);
Transaction.commit(connection);
return result;
}
}
/**
* Retrieve multiple objects by pk.
*
* @param pks List of primary keys.
* Entries in pks which do not match entries in the database are ignored.
* @param dbcon the connection to use
*
* @return the list of matching objects, not null.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public List<JobEntryTorque> retrieveByTypedPKs(
Collection<Integer> pks,
Connection dbcon)
throws TorqueException
{
if (pks == null || pks.size() == 0)
{
return new ArrayList<JobEntryTorque>();
}
List<ObjectKey<?>> objectKeyList = new ArrayList<ObjectKey<?>>();
for (Integer pk : pks)
{
objectKeyList.add(SimpleKey.keyFor(pk));
}
Criteria criteria = buildCriteria(objectKeyList);
List<JobEntryTorque> result = doSelect(criteria, dbcon);
return result;
}
/**
* Retrieve multiple objects by pk.
*
* @param pks List of primary keys.
* Entries in pks which do not match entries in the database are ignored.
*
* @return the list of matching objects, not null.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public List<JobEntryTorque> retrieveByObjectKeys(Collection<ObjectKey<?>> pks)
throws TorqueException
{
try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
{
List<JobEntryTorque> result = retrieveByObjectKeys(pks, connection);
Transaction.commit(connection);
return result;
}
}
/**
* Retrieve multiple objects by pk.
*
* @param pks List of primary keys.
* Entries in pks which do not match entries in the database are ignored.
* @param dbcon the connection to use
*
* @return the list of matching objects, not null.
*
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
public List<JobEntryTorque> retrieveByObjectKeys(
Collection<ObjectKey<?>> pks,
Connection dbcon)
throws TorqueException
{
if (pks == null || pks.size() == 0)
{
return new ArrayList<JobEntryTorque>();
}
Criteria criteria = buildCriteria(pks);
List<JobEntryTorque> result = doSelect(criteria, dbcon);
return result;
}
}