本文整理汇总了Java中org.apache.tapestry5.hibernate.annotations.CommitAfter类的典型用法代码示例。如果您正苦于以下问题:Java CommitAfter类的具体用法?Java CommitAfter怎么用?Java CommitAfter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommitAfter类属于org.apache.tapestry5.hibernate.annotations包,在下文中一共展示了CommitAfter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBookmark
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
protected StockEditor onBookmark(long id) {
if (id < 1) {
return this;
}
Bookmark bm = (Bookmark) session.get(Bookmark.class, id);
if (bm == null) {
alertManager.alert(Duration.SINGLE, Severity.INFO, messages.get("bookmark-set"));
bm = new Bookmark();
bm.setId(id);
session.save(bm);
}
else {
alertManager.alert(Duration.SINGLE, Severity.INFO, messages.get("bookmark-deleted"));
session.delete(bm);
}
return this;
}
示例2: doDelete
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
private Object doDelete() {
try {
Stock bye = (Stock) session.get(Stock.class, stockId);
long byeid = bye.getId();
bye.setName(null);
bye.setVariant(null);
session.delete(bye);
focusedStockId = 0;
Bookmark bm = (Bookmark) session.get(Bookmark.class, byeid);
if (bm != null) {
session.delete(bm);
}
alertManager.alert(Duration.SINGLE, Severity.SUCCESS,
messages.format("delete-success", byeid));
eventLogger.deleted(bye);
}
catch (Exception e) {
alertManager.alert(Duration.SINGLE, Severity.ERROR,
messages.format("exception", e.getMessage()));
// Only two ways of getting here: trying to delete something that no
// longer exists or never existed in the first place. No need to tell the
// user that throwing away something non-existant failed.
}
return Index.class;
}
示例3: onMerge
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
protected void onMerge(long id) {
try {
Stock m = (Stock) session.load(Stock.class, id);
Stock backup = (Stock) session.load(Stock.class, id);
// Hibernate doesn't like an update and a delete in the same transaction
// when this leads to the same row in a OneToMany mapping. Since we are
// deleting "m" anyways, we can stop the cascade simply by setting the
// references to null.
m.setName(null);
m.setVariant(null);
stock.setUnitCount(stock.getUnitCount() + m.getUnitCount());
session.update(stock);
session.delete(m);
eventLogger.merged(stock, backup);
}
catch (Exception e) {
e.printStackTrace();
alertManager.alert(Duration.SINGLE, Severity.ERROR,
messages.format("exception", e.getMessage()));
}
}
示例4: onSuccessFromCommitForm
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
public Object onSuccessFromCommitForm() {
if (parsed == null) {
return this;
}
int count = 0;
for (Stock stock : parsed) {
// We have to repack name/variant here because it is highly likely that
// the CSV contains a label several times which is not yet known to the
// database. So we need a save() after every findName() to make sure we
// don't violate the unique constraint.
stock.setName(IdentUtil.findName(session, stock.getName().getLabel()));
Variant v = stock.getVariant();
if (v != null) {
stock.setVariant(IdentUtil.findVariant(session, stock.getVariant().getLabel()));
}
session.save(stock);
eventLogger.acquired(stock);
count++;
}
alertManager.alert(Duration.SINGLE, Severity.SUCCESS, messages.format("success", count));
parsed = null;
return Index.class;
}
示例5: setupRender
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
protected void setupRender() {
try {
stock = (Stock) session.get(Stock.class, stockId);
if (stock == null) {
stock = new Stock();
stock.setAcquired(new Date());
stock.setUnitCount(1);
if (stockId > 0) {
alertManager.alert(Duration.SINGLE, Severity.INFO, messages.format("not-found", stockId));
Bookmark bm = (Bookmark) session.get(Bookmark.class, stockId);
if (bm != null) {
// This is a failsave in case something deletes stock but not
// bookmarks. Normally we shouldn't get here.
session.delete(bm);
}
}
}
if (stock.getName() != null) {
name = stock.getName().getLabel();
}
if (stock.getVariant() != null) {
variant = stock.getVariant().getLabel();
}
units = stock.getUnitCount();
// NOTE: fill buyPrice/sellPrice even if acquired/liquidated is null. The
// user might have entered expected prices!
buyPrice = moneyRepresentation.databaseToUser(stock.getBuyPrice(), true, false);
sellPrice = moneyRepresentation.databaseToUser(stock.getSellPrice(), true, false);
acquired = stock.getAcquired();
liquidated = stock.getLiquidated();
liquidateable = (liquidated == null && stock.getId() > 0);
comment = stock.getComment();
splitable = stock.getUnitCount() > 1;
location=stock.getLocation();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例6: doSave
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
private Object doSave() {
Object ret = null;
try {
stock = (Stock) session.get(Stock.class, stockId);
Stock backup = null;
if (stock == null) {
stock = new Stock();
}
else {
backup = new Stock(stock);
}
stock.setName(IdentUtil.findName(session, name));
stock.setVariant(IdentUtil.findVariant(session, variant));
stock.setAcquired(acquired);
stock.setLiquidated(liquidated);
stock.setSellPrice(moneyRepresentation.userToDatabase(sellPrice, 1));
stock.setBuyPrice(moneyRepresentation.userToDatabase(buyPrice, 1));
stock.setUnitCount(units);
stock.setComment(comment);
stock.setLocation(location);
session.saveOrUpdate(stock);
alertManager.alert(Duration.SINGLE, Severity.SUCCESS,
messages.format("save-success", stock.getId()));
focusedStockId = stock.getId();
if (backup == null) {
eventLogger.acquired(stock);
ret = this;
}
else {
eventLogger.modified(backup);
ret = Index.class;
}
}
catch (Exception e) {
alertManager.alert(Duration.SINGLE, Severity.ERROR,
messages.format("exception", e.getMessage()));
}
return ret;
}
示例7: onSuccessFromSellForm
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
protected Object onSuccessFromSellForm() {
try {
Stock s = (Stock) session.load(Stock.class, stockId);
long sp = 0;
if (methods == Payment.PERUNIT) {
sp = moneyRepresentation.userToDatabase(sellPrice, 1);
}
else {
sp = moneyRepresentation.userToDatabase(sellPrice, s.getUnitCount());
}
s.setLiquidated(new Date());
s.setSellPrice(sp);
focusedStockId = s.getId();
String profit = moneyRepresentation.databaseToUser((s.getSellPrice() - s.getBuyPrice()) * s.getUnitCount(),
false, true);
alertManager.alert(Duration.SINGLE, Severity.SUCCESS,
messages.format("liquidate-success", stockId, profit));
eventLogger.liquidated(s);
}
catch (Exception e) {
// TODO: Figure out how we got here and give the user better feedback
e.printStackTrace();
alertManager.alert(Duration.SINGLE, Severity.WARN, messages.format("internal error"));
return null;
}
return Index.class;
}
示例8: onSuccess
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
public Object onSuccess() {
if (eventDelete) {
doDelete();
}
else {
doSave();
}
return LabelManager.class;
}
示例9: onSuccess
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
protected Object onSuccess() {
try {
Stock offspring = stock.splitStock(size);
session.save(offspring);
session.update(stock);
eventLogger.split(stock, offspring);
}
catch (Exception e) {
alertManager.alert(Duration.SINGLE, Severity.ERROR,
messages.format("exception", e.getMessage()));
e.printStackTrace();
}
return getClass();
}
示例10: onSuccessFromBuyForm
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
public Object onSuccessFromBuyForm() {
Stock item = new Stock();
item.setName(IdentUtil.findName(session, buyName));
item.setVariant(IdentUtil.findVariant(session, buyVariant));
try {
item.setBuyPrice(moneyRepresentation.userToDatabase(buyCost, 1));
item.setSellPrice(moneyRepresentation.userToDatabase(buyReturns, 1));
}
catch (ParseException e) {
// We already validated this
}
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MINUTE, 0);
now.set(Calendar.HOUR_OF_DAY, 0);
item.setLocation(buyLocation);
item.setUnitCount(buyAmount);
item.setAcquired(now.getTime());
session.persist(item);
focusedStockId = item.getId();
eventLogger.acquired(item);
withNoFilters();
ledger.reset();
autofocusBuyForm = true;
return Index.class;
}
示例11: onSuccessFromActionForm
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
public LabelManager onSuccessFromActionForm() {
if (actions == LabelActions.TRIM) {
trimLabels();
alertManager.alert(Duration.SINGLE,Severity.INFO,messages.format("deleted",affected));
}
else {
sanitizeLabels();
alertManager.alert(Duration.SINGLE,Severity.INFO,messages.format("updated",affected));
}
return this;
}
示例12: add
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
void add(User user);
示例13: add
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
void add(News news);
示例14: incLike
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
News incLike(int newsId);
示例15: delete
import org.apache.tapestry5.hibernate.annotations.CommitAfter; //导入依赖的package包/类
@CommitAfter
News delete(int newsId);