Java代碼
public class ClassA{public void saveUser(User user){
session = sessionFactory
Transaction tx = session
session
tx
session
}
}
public class ClassB{
public void saveOrder(Order order){
session = sessionFactory
Transaction tx = session
session
tx
session
}
}
public class ClassC{
public void save(){
……
UserTransaction tx = new InitialContext()
ClassA
ClassB
tx
……
}
}
public class ClassA{
public void saveUser(User user){
session = sessionFactory
Transaction tx = session
session
tx
session
}
}
public class ClassB{
public void saveOrder(Order order){
session = sessionFactory
Transaction tx = session
session
tx
session
}
}
public class ClassC{
public void save(){
……
UserTransaction tx = new InitialContext()
ClassA
ClassB
tx
……
}
這裡有兩個類ClassA和ClassB
[
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29039.html