📄 maintestforcallbackpreferringplatformtransactionmanager.java
字号:
package org.springframework.samples;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.samples.petclinic.Clinic;
import org.springframework.samples.petclinic.Owner;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
/**
*
* @author worldheart
*
*/
public class MainTestForCallbackPreferringPlatformTransactionManager {
public static void main(String[] args) {
ListableBeanFactory cbf = new ClassPathXmlApplicationContext("ac6.xml");
GenericBeanFactoryAccessor gbfa = new GenericBeanFactoryAccessor(cbf);
Clinic clinic = gbfa.getBean("hsqlClinic");
Owner owner = new Owner();
owner.setAddress("XiDan");
owner.setCity("Beijing");
owner.setFirstName("FirstName");
owner.setLastName("LastName");
owner.setTelephone("888888");
DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
dtd.setTimeout(120);
PlatformTransactionManager ptm = gbfa.getBean("transactionManager");
TransactionStatus ts = ptm.getTransaction(dtd);
clinic.storeOwner(owner);
ptm.commit(ts);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -