Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 271316 Details for
Bug 522635
ConcurrentModificationException when triggering lazy load from conforming query
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Entities and testcode
file_522635.txt (text/plain), 4.43 KB, created by
thorsten kruse
on 2017-11-03 09:00:06 EDT
(
hide
)
Description:
Entities and testcode
Filename:
MIME Type:
Creator:
thorsten kruse
Created:
2017-11-03 09:00:06 EDT
Size:
4.43 KB
patch
obsolete
>@Entity >@Table(name="TKE_PERSISTENTOBJECT") >@Inheritance(strategy=InheritanceType.JOINED) >public abstract class PersistentObject >{ > @Id > @GeneratedValue(strategy=GenerationType.SEQUENCE) > private long id; > > //just a non-id field > private long timestamp; > > public long getTimestamp() { > return timestamp; > } > > public void setTimestamp(long timestamp) > { > this.timestamp = timestamp; > } >} > > >@Entity >@Table(name="TKE_EMPLOYEEPO") >public class EmployeePO extends PersistentObject >{ > public EmployeePO() > { > } > > public EmployeePO(String name, long timestamp) > { > super(); > this.name = name; > setTimestamp(timestamp); > } > > private String name; > > @OneToMany(mappedBy="employee") > private List<ContactPO> contacts = new ArrayList<>(); > > public void addContact(ContactPO c) > { > if ( c != null ) > { > this.contacts.add(c); > c.employee = this; > } > } > > @Override > public String toString() > { > return "[" + name + "]"; > } >} > > >@Entity >@Table(name="tke_CustomerPO") >public class CustomerPO extends PersistentObject >{ > public CustomerPO() > { > } > > public CustomerPO(String name, long timestamp) > { > super(); > this.name = name; > setTimestamp(timestamp); > } > > @OneToMany(mappedBy="customer") > private List<ContactPO> contacts = new ArrayList<>(); > > private String name; > > public void addContact(ContactPO c) > { > if ( c != null ) > { > this.contacts.add(c); > c.customer = this; > } > } > > @Override > public String toString() { > return "[" + name + "]"; > } >} > > >@Entity >@Table(name="tke_ContactPO") >public class ContactPO extends PersistentObject >{ > public ContactPO() > { > super(); > } > > public ContactPO(long timestamp) > { > super(); > setTimestamp(timestamp); > } > > @ManyToOne(fetch=FetchType.LAZY) > public CustomerPO customer; > > @ManyToOne(fetch=FetchType.LAZY) > public EmployeePO employee; > > public int daysVisted; > > @Override > public String toString() { > return customer + " <-> " + employee + ", daysVisted=" + daysVisted; > } >} > > >public class Main_bug522635 >{ > private static EmployeePO getNewEmployee(String name, UnitOfWork uow) > { > EmployeePO emp = new EmployeePO(name, System.currentTimeMillis()); > uow.registerNewObject(emp); > return emp; > } > > private static CustomerPO getNewCustomer(String name, UnitOfWork uow) > { > CustomerPO cus = new CustomerPO(name, System.currentTimeMillis()); > uow.registerNewObject(cus); > return cus; > } > > private static ContactPO getNewContact(UnitOfWork uow) > { > ContactPO con = new ContactPO(System.currentTimeMillis()); > uow.registerNewObject(con); > return con; > } > > private static ReadAllQuery getNewReadAllQuery(Class<?> c) > { > ReadAllQuery raq = new ReadAllQuery(c); > raq.conformResultsInUnitOfWork(); > raq.setInMemoryQueryIndirectionPolicy(new InMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION)); > return raq; > } > > > //store entities to DB > private static void doInit() > { > UnitOfWork uow = DBSessionProvider.getInstance().getClientSession().acquireUnitOfWork(); > > EmployeePO bob = getNewEmployee("Bob", uow); > EmployeePO paul = getNewEmployee("Paul", uow); > > CustomerPO compA = getNewCustomer("CompA", uow); > CustomerPO compB = getNewCustomer("CompB", uow); > > ContactPO con1 = getNewContact(uow); > con1.daysVisted = 5; > bob.addContact(con1); > compA.addContact(con1); > > ContactPO con2 = getNewContact(uow); > con2.daysVisted = 10; > paul.addContact(con2); > compA.addContact(con2); > > ContactPO con3 = getNewContact(uow); > con3.daysVisted = 5; > paul.addContact(con3); > compB.addContact(con3); > > uow.commit(); > uow.release(); > } > > > /** > * weaving has to be active! > */ > private static void doMain() > { > UnitOfWork uow = DBSessionProvider.getInstance().getClientSession().acquireUnitOfWork(); > > ReadAllQuery raqCon = getNewReadAllQuery(ContactPO.class); > ExpressionBuilder ebCon = new ExpressionBuilder(); > raqCon.setSelectionCriteria(ebCon.get("customer").get("name").equal("CompA")); > uow.executeQuery(raqCon); > //execute query again > uow.executeQuery(raqCon); //NoSuchElementException > > uow.release(); > } > > > public static void main(String args[]) > { >// doInit(); > doMain(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 522635
: 271316 |
271946