本文整理匯總了Java中javax.transaction.HeuristicMixedException類的典型用法代碼示例。如果您正苦於以下問題:Java HeuristicMixedException類的具體用法?Java HeuristicMixedException怎麽用?Java HeuristicMixedException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HeuristicMixedException類屬於javax.transaction包,在下文中一共展示了HeuristicMixedException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testPasswordConverter
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
@Test
public void testPasswordConverter() {
logger.info("starting persistence converter test");
Citizen citizen = new Citizen();
citizen.setPassword("prova");
try {
userTransaction.begin();
entityManager.persist(citizen);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
Citizen citizenFromDB = (Citizen) entityManager.createQuery("from citizen").getSingleResult();
assertEquals("the password is always converted by the converter", "prova", citizenFromDB.getPassword());
assertEquals("this is the password we have in the database", "cHJvdmE=", NEVER_DO_IT);
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:18,代碼來源:ConverterTestCase.java
示例2: testSingleTable
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
/**
* Tests annotation literals in a jar archive
*/
@Test
@SuppressWarnings("unchecked")
public void testSingleTable() {
logger.info("starting single table inheritance test");
Pet pet = new Pet("jackrussell", "dog");
Dog dog = new Dog("mastino", "dog");
try {
userTransaction.begin();
entityManager.persist(pet);
entityManager.persist(dog);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
List<Pet> petsFromDB = entityManager.createNativeQuery("select * from pet").getResultList();
assertEquals("only the pet table exists", 2, petsFromDB.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:22,代碼來源:InheritanceTestCase.java
示例3: testTablePerClass
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
/**
* Tests annotation literals in a jar archive
*/
@Test
@SuppressWarnings("unchecked")
public void testTablePerClass() {
logger.info("starting table per class inheritance test");
Vehicle vehicle = new Vehicle("peugeot", "car");
Car car = new Car("fiat", "car");
try {
userTransaction.begin();
entityManager.persist(vehicle);
entityManager.persist(car);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
List<Vehicle> vehiclesFromDB = entityManager.createNativeQuery("select * from vehicle").getResultList();
assertEquals("the vehicle table exists", 1, vehiclesFromDB.size());
List<Car> carsFromDB = entityManager.createNativeQuery("select * from car").getResultList();
assertEquals("the car table exists", 1, carsFromDB.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:24,代碼來源:InheritanceTestCase.java
示例4: testJoin
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
/**
* Tests annotation literals in a jar archive
*/
@Test
@SuppressWarnings("unchecked")
public void testJoin() {
logger.info("starting joined inheritance event test");
Watch watch = new Watch();
TopicWatch topicWatch = new TopicWatch();
try {
userTransaction.begin();
entityManager.persist(watch);
entityManager.persist(topicWatch);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
List<Watch> watchesFromDB = entityManager.createNativeQuery("select * from JBP_FORUMS_WATCH").getResultList();
assertEquals("the watch table exists", 2, watchesFromDB.size());
List<TopicWatch> topicWatchesFromDB = entityManager.createNativeQuery("select * from JBP_FORUMS_TOPICSWATCH")
.getResultList();
assertEquals("the topic watch table exists", 1, topicWatchesFromDB.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:25,代碼來源:InheritanceTestCase.java
示例5: testSearch
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
@Test
public void testSearch() {
Forum forum = entityManager.find(Forum.class, 0);
Poster poster = new Poster("root");
Topic topic = new Topic(forum, TOPIC_TEXT);
topic.setPoster(poster);
Post post = new Post(topic, POST_TEXT);
post.setCreateDate(new Date());
post.setPoster(poster);
try {
userTransaction.begin();
entityManager.persist(poster);
entityManager.persist(topic);
entityManager.persist(post);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
e.printStackTrace();
}
List<Topic> topics = findTopics();
List<Post> posts = findPosts();
assertEquals("find topics", 1, topics.size());
assertEquals("find posts", 1, posts.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:25,代碼來源:SearchTestCase.java
示例6: testDeleteManyToMany
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
@Test
public void testDeleteManyToMany() {
logger.info("starting merge many to many cascade test");
testPersistManyToMany();
try {
userTransaction.begin();
Author davide_scala = (Author) entityManager.createQuery("from Author where fullName = :fullName")
.setParameter("fullName", "Davide Scala").getSingleResult();
davide_scala.remove();
entityManager.remove(davide_scala);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
@SuppressWarnings("unchecked")
List<Book> booksFromDb = entityManager.createNativeQuery("select * from Book").getResultList();
assertEquals("the book table exists", 2, booksFromDb.size());
@SuppressWarnings("unchecked")
List<Author> authorsFromDb = entityManager.createNativeQuery("select * from Author").getResultList();
assertEquals("the author table exists", 2, authorsFromDb.size());
@SuppressWarnings("unchecked")
List<Author> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_Author").getResultList();
assertEquals("the author table exists", 4, bookAuthorsFromDb.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:26,代碼來源:CascadeTestCase.java
示例7: testDeleteBooksAllManyToMany
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
@Test
public void testDeleteBooksAllManyToMany() {
logger.info("starting merge many to many cascade test");
testPersistManyToMany();
try {
userTransaction.begin();
PMAuthor davide_scala = (PMAuthor) entityManager.createQuery("from PMAuthor where fullName = :fullName")
.setParameter("fullName", "Davide Scala").getSingleResult();
entityManager.remove(davide_scala);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
@SuppressWarnings("unchecked")
List<PMBook> booksFromDb = entityManager.createNativeQuery("select * from PMBook").getResultList();
assertEquals("the pm book table exists", 1, booksFromDb.size());
@SuppressWarnings("unchecked")
List<PMAuthor> authorsFromDb = entityManager.createNativeQuery("select * from PMAuthor").getResultList();
assertEquals("the pm author table exists", 2, authorsFromDb.size());
@SuppressWarnings("unchecked")
List<PMAuthor> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_PM_Author")
.getResultList();
assertEquals("the pm book author table exists", 2, bookAuthorsFromDb.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:26,代碼來源:CascadeTestCase.java
示例8: testDeleteBooksJoinTableAllManyToMany
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
@Test
public void testDeleteBooksJoinTableAllManyToMany() {
logger.info("starting merge many to many cascade test");
testPersistManyToMany();
try {
userTransaction.begin();
AllAuthor davide_scala = (AllAuthor) entityManager.createQuery("from AllAuthor where fullName = :fullName")
.setParameter("fullName", "Davide Scala").getSingleResult();
entityManager.remove(davide_scala);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
@SuppressWarnings("unchecked")
List<AllBook> booksFromDb = entityManager.createNativeQuery("select * from AllBook").getResultList();
assertEquals("the all book table doesn't exist", 0, booksFromDb.size());
@SuppressWarnings("unchecked")
List<AllAuthor> authorsFromDb = entityManager.createNativeQuery("select * from AllAuthor").getResultList();
assertEquals("the all author table doesn't exist", 0, authorsFromDb.size());
@SuppressWarnings("unchecked")
List<AllAuthor> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_All_Author")
.getResultList();
assertEquals("the all book author table exists", 0, bookAuthorsFromDb.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:26,代碼來源:CascadeTestCase.java
示例9: testSimpleTransaction
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
/**
* Tests the fire of the event inside a transaction
*/
@Test
public void testSimpleTransaction() {
try {
userTransaction.begin();
Bill bill = fire();
assertEquals(
"The id generation passes through the always and it is incremented only by inprogess always observer method",
1, bill.getId());
userTransaction.commit();
assertEquals(
"The id generation passes through the always and it is incremented only by transactional observer methods",
4, bill.getId());
} catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException
| HeuristicMixedException | HeuristicRollbackException e) {
fail("no fail for the transaction");
}
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:22,代碼來源:EventTestCase.java
示例10: commit
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
SecurityException, SystemException
{
try
{
if (isRollBackOnly)
{
throw new RollbackException("Commit failed: Transaction marked for rollback");
}
}
finally
{
transaction.set(null);
}
}
示例11: createUsers
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
private void createUsers() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException, NotSupportedException
{
txn = transactionService.getUserTransaction();
txn.begin();
for (UserInfo user : userInfos)
{
String username = user.getUserName();
NodeRef nodeRef = personService.getPersonOrNull(username);
boolean create = nodeRef == null;
if (create)
{
PropertyMap testUser = new PropertyMap();
testUser.put(ContentModel.PROP_USERNAME, username);
testUser.put(ContentModel.PROP_FIRSTNAME, user.getFirstName());
testUser.put(ContentModel.PROP_LASTNAME, user.getLastName());
testUser.put(ContentModel.PROP_EMAIL, user.getUserName() + "@acme.test");
testUser.put(ContentModel.PROP_PASSWORD, "password");
nodeRef = personService.createPerson(testUser);
}
userNodeRefs.add(nodeRef);
// System.out.println((create ? "create" : "existing")+" user " + username + " nodeRef=" + nodeRef);
}
txn.commit();
}
示例12: multipleCloseTest
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
@Test
@DisplayName( "Multiple close test" )
public void multipleCloseTest() throws SQLException {
TransactionManager txManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
TransactionSynchronizationRegistry txSyncRegistry = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple();
AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier()
.connectionPoolConfiguration( cp -> cp
.transactionIntegration( new NarayanaTransactionIntegration( txManager, txSyncRegistry ) )
);
try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) {
// there is a call to connection#close in the try-with-resources block and another on the callback from the transaction#commit()
try ( Connection connection = dataSource.getConnection() ) {
logger.info( format( "Got connection {0}", connection ) );
try {
txManager.begin();
txManager.commit();
} catch ( NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e ) {
fail( "Exception: " + e.getMessage() );
}
}
}
}
示例13: configTest
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
/**
* Configuración inicial de la prueba.
*
* @generated
*/
@Before
public void configTest()
{
try {
utx.begin();
clearData();
insertData();
utx.commit();
} catch (IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | NotSupportedException | RollbackException | SystemException e) {
e.printStackTrace();
try {
utx.rollback();
} catch (IllegalStateException | SecurityException | SystemException e1) {
e1.printStackTrace();
}
}
}
示例14: configTest
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
/**
* Configuración inicial de la prueba.
*
* @generated
*/
@Before
public void configTest() {
try {
utx.begin();
clearData();
insertData();
utx.commit();
} catch (IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | NotSupportedException | RollbackException | SystemException e) {
e.printStackTrace();
try {
utx.rollback();
} catch (IllegalStateException | SecurityException | SystemException e1) {
e1.printStackTrace();
}
}
}
示例15: getUserTransaction
import javax.transaction.HeuristicMixedException; //導入依賴的package包/類
public UserTransaction getUserTransaction() {
return new UserTransaction() {
public void begin() throws NotSupportedException, SystemException {
}
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
}
public int getStatus() throws SystemException {
return TransactionUtil.STATUS_NO_TRANSACTION;
}
public void rollback() throws IllegalStateException, SecurityException, SystemException {
}
public void setRollbackOnly() throws IllegalStateException, SystemException {
}
public void setTransactionTimeout(int i) throws SystemException {
}
};
}