本文整理汇总了Java中javax.persistence.StoredProcedureQuery.setParameter方法的典型用法代码示例。如果您正苦于以下问题:Java StoredProcedureQuery.setParameter方法的具体用法?Java StoredProcedureQuery.setParameter怎么用?Java StoredProcedureQuery.setParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.StoredProcedureQuery
的用法示例。
在下文中一共展示了StoredProcedureQuery.setParameter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculate
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
@Test
public void calculate() {
log.info("... calculate ...");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
// define the stored procedure
StoredProcedureQuery query = em.createStoredProcedureQuery("calculate");
query.registerStoredProcedureParameter("x", Double.class, ParameterMode.IN);
query.registerStoredProcedureParameter("y", Double.class, ParameterMode.IN);
query.registerStoredProcedureParameter("sum", Double.class, ParameterMode.OUT);
// set input parameter
query.setParameter("x", 1.23d);
query.setParameter("y", 4d);
// call the stored procedure and get the result
query.execute();
Double sum = (Double) query.getOutputParameterValue("sum");
log.info("Calculation result: 1.23 + 4 = " + sum);
em.getTransaction().commit();
em.close();
}
示例2: calculate
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
@Test
public void calculate() {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("calculate");
query.setParameter("x", 1.23d);
query.setParameter("y", 4d);
query.execute();
Double sum = (Double) query.getOutputParameterValue("sum");
log.info("Calculation result: 1.23 + 4 = " + sum);
em.getTransaction().commit();
em.close();
}
示例3: runBackup
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
/**
* Creates a Backup of the Database in the directory specified in
* config.properties.
*
* @param name the name of the Backup.
*
* @return Backup entinty.
*
* @throws QueryTimeoutException if the query should fail.
* @throws PersistenceException if persisting should fail.
* @Throws IOException if config.properties is not readable.
*/
public Backup runBackup(String name) throws QueryTimeoutException,
PersistenceException, IOException {
Properties props = ServerProperties.getProperties();
Date date = new Date();
String path = props.getProperty(dirPropertyKey)
+ name + "_" + getDateAsString(date);
StoredProcedureQuery query = em.createStoredProcedureQuery(
"SYSCS_UTIL.SYSCS_BACKUP_DATABASE");
query.registerStoredProcedureParameter(1, String.class,
ParameterMode.IN);
query.setParameter(1, path);
query.execute();
log.debug("Backup query executed!");
Backup backup = generateBackup(name, path, date, getDirectorySize(new File(path)));
return backup;
}
示例4: isNowHoliday
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
/**
* Checks whether the current day is a holiday.
*
* @param now The current day.
* @return True if the current date is a holiday, false otherwise.
* @throws BatchProcessingException If major error occurred.
*/
protected boolean isNowHoliday(Date now) throws BatchProcessingException {
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY) {
return true; // Sunday for 0 and Saturday for 6 are holidays
}
try {
startTransaction();
StoredProcedureQuery sp = entityManager.createNamedStoredProcedureQuery("IsThisHoliday");
sp.setParameter("pDate2Test", now, TemporalType.DATE);
Boolean result = (Boolean) sp.getSingleResult();
commitTransaction();
return result;
} catch (PersistenceException pe) {
throw new BatchProcessingException("Database error checking holiday.", pe);
}
}
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:32,代码来源:BatchProcessingJob.java
示例5: batchDailyAccountUpdate
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
/**
* Batch daily account update.
* <p/>
* This method does not throw any exception.
*
* @param procMessage The process message. Used to build the mail message.
* @return true if execution is successful; false otherwise.
*/
private boolean batchDailyAccountUpdate(StringBuilder procMessage) {
try {
startTransaction();
StoredProcedureQuery sp = entityManager.createNamedStoredProcedureQuery("BatchDailyAccountUpdate");
sp.setParameter("pAuditBatchIDLog", todayAuditBatch.getId());
Integer count = (Integer) sp.getSingleResult();
commitTransaction();
String msg = "Updated " + count + " master records to history or ACH Stop status.";
logger.info(msg);
procMessage.append(CRLF).append(CRLF).append(msg);
return true;
} catch (PersistenceException pe) {
logger.error("ERROR: Updating master records to history or ACH Stop status failed.", pe);
procMessage.append(CRLF).append(CRLF)
.append("ERROR: Updating master records to history or ACH Stop status failed. ");
return false;
}
}
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:32,代码来源:BatchProcessingJob.java
示例6: testCallStoreProcedure
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
@Test
public void testCallStoreProcedure() {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("my_sum");
query.registerStoredProcedureParameter("x", Integer.class, IN);
query.registerStoredProcedureParameter("y", Integer.class, IN);
query.setParameter("x", 5);
query.setParameter("y", 4);
query.execute();
Integer sum = (Integer) query.getSingleResult();
assertEquals("the sum in the stored procedure", sum, new Integer(9));
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:14,代码来源:StoreProcedureTestCase.java
示例7: plainJpa21
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
@Test
public void plainJpa21() {
StoredProcedureQuery proc = em.createStoredProcedureQuery("plus1inout");
proc.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN);
proc.registerStoredProcedureParameter(2, Integer.class, ParameterMode.OUT);
proc.setParameter(1, 1);
proc.execute();
assertThat(proc.getOutputParameterValue(2), is((Object) 2));
}
示例8: save
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
/**
* Saves a bid to the database
* @param bid - bid
*/
public void save(Bid bid) {
entityManager.persist(bid);
StoredProcedureQuery spq = entityManager.createStoredProcedureQuery("getQtyOrders");
spq.registerStoredProcedureParameter("param1", Integer.class, ParameterMode.IN);
spq.setParameter("param1",55);
Object[] count = (Object[])spq.getSingleResult();
logger.log(Level.INFO, "Single result: {0}", count[0]);
}
示例9: aggregateResults
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
public void aggregateResults(Long processingId) {
StoredProcedureQuery query = createProcedureQuery("aggregate_results");
query.registerStoredProcedureParameter("process_id", Long.class, ParameterMode.IN);
query.setParameter("process_id", processingId);
query.execute();
}
示例10: plainJpa21_entityAnnotatedCustomNamedProcedurePlus1IO
import javax.persistence.StoredProcedureQuery; //导入方法依赖的package包/类
@Test
public void plainJpa21_entityAnnotatedCustomNamedProcedurePlus1IO() {
StoredProcedureQuery proc = em.createNamedStoredProcedureQuery("User.plus1");
proc.setParameter("arg", 1);
proc.execute();
assertThat(proc.getOutputParameterValue("res"), is((Object) 2));
}