Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » PostLoad on a new instance?
PostLoad on a new instance? [message #383031] Tue, 18 November 2008 12:21 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
I don't get this.

I've implemented a PostLoad event listener on Batchtransferline (in fact on the inherited AbstractBean, but that's just a detail). The intention is to hold on to some load-time values, so that at save time changes can easily be detected.

The Batchtransferline is then shown in a JTable. In the stacktrace below you see a call to:
BatchtransferToBatchtransferlineTableModelForEdit.setValueAt

This is the result of an articlenr being entered in a cell in the JTable and the corresponding Article entity is searched and found.
Moving up the trace one line; setting the article on the Batchtransferline also results in the Batchtransferline being added to the collection in Article.
That results in the collection being lazy loaded.
Now a whole bunch of EclipseLink stuff is happening and all of a sudden I'm in my PostLoad handler.
WTF? This is a newly created instance, how can I get in a PostLoad handler???


Thread [AWT-EventQueue-1] (Suspended (breakpoint at line 48 in Batchtransferline))
Batchtransferline.postLoadHook() line: 48
Batchtransferline(AbstractBean).postLoad() line: 222
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
PrivilegedAccessHelper.invokeMethod(Method, Object, Object[]) line: 344
EntityClassListener(EntityListener).invokeMethod(Method, Object, Object[], DescriptorEvent) line: 297
EntityClassListener.invokeMethod(String, DescriptorEvent) line: 64
EntityClassListener(EntityListener).postBuild(DescriptorEven t) line: 370
DescriptorEventManager.notifyListener(DescriptorEventListene r, DescriptorEvent) line: 635
DescriptorEventManager.notifyEJB30Listeners(DescriptorEvent) line: 593
DescriptorEventManager.executeEvent(DescriptorEvent) line: 187
ObjectBuilder.buildAttributesIntoWorkingCopyClone(Object, ObjectBuildingQuery, JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, boolean) line: 1260
ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuildingQue ry, JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, Vector) line: 1355
ObjectBuilder.buildObjectInUnitOfWork(ObjectBuildingQuery, JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, Vector, ClassDescriptor) line: 513
ObjectBuilder.buildObject(ObjectBuildingQuery, AbstractRecord, JoinedAttributeManager) line: 461
ObjectBuilder.buildObject(ObjectLevelReadQuery, AbstractRecord) line: 413
ReadAllQuery(ObjectLevelReadQuery).buildObject(AbstractRecor d) line: 521
ReadAllQuery.registerResultInUnitOfWork(Object, UnitOfWorkImpl, AbstractRecord, boolean) line: 893
ReadAllQuery.executeObjectLevelReadQuery() line: 486
ReadAllQuery(ObjectLevelReadQuery).executeDatabaseQuery() line: 879
ReadAllQuery(DatabaseQuery).execute(AbstractSession, AbstractRecord) line: 666
ReadAllQuery(ObjectLevelReadQuery).execute(AbstractSession, AbstractRecord) line: 840
ReadAllQuery.execute(AbstractSession, AbstractRecord) line: 456
ReadAllQuery(ObjectLevelReadQuery).executeInUnitOfWork(UnitO fWorkImpl, AbstractRecord) line: 902
RepeatableWriteUnitOfWork(UnitOfWorkImpl).internalExecuteQue ry(DatabaseQuery, AbstractRecord) line: 2587
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(Data baseQuery, AbstractRecord, int) line: 1178
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(Data baseQuery, AbstractRecord) line: 1162
QueryBasedValueHolder.instantiate(AbstractSession) line: 77
QueryBasedValueHolder.instantiate() line: 67
QueryBasedValueHolder(DatabaseValueHolder).getValue() line: 83
UnitOfWorkQueryValueHolder(UnitOfWorkValueHolder).instantiat eImpl() line: 161
UnitOfWorkQueryValueHolder(UnitOfWorkValueHolder).instantiat e() line: 230
UnitOfWorkQueryValueHolder(DatabaseValueHolder).getValue() line: 83
IndirectList.buildDelegate() line: 213
IndirectList.getDelegate() line: 379
IndirectList.contains(Object) line: 310
Article(Article).addBatchtransferlinesWhereIAmArticle(Batcht ransferline) line: 184
Batchtransferline(Batchtransferline).setArticle(Article) line: 87
BatchtransferToBatchtransferlineTableModelForEdit.setValueAt (Object, int, int) line: 158
TableSorterForEdit(TableSorter).setValueAt(Object, int, int) line: 369
BatchtransferToBatchtransferlineTableForEdit(JXTable).setVal ueAt(Object, int, int) line: 1396
BatchtransferToBatchtransferlineTableForEdit(JTable).editing Stopped(ChangeEvent) line: 4721
BatchtransferToBatchtransferlineTableForEdit(JTableForEdit). editingStopped(ChangeEvent) line: 523
ArticleTableCellEditor(AbstractCellEditor).fireEditingStoppe d() line: 125
ArticleTableCellEditor(AbstractCellEditor).stopCellEditing() line: 68
ArticleTableCellEditor(JpaEntityTableCellEditor<T>).stopCellEditing() line: 166
BasicTableUI$Actions.actionPerformed(ActionEvent) line: 475
SwingUtilities.notifyAction(Action, KeyStroke, KeyEvent, Object, int) line: 1636
BatchtransferToBatchtransferlineTableForEdit(JComponent).pro cessKeyBinding(KeyStroke, KeyEvent, int, boolean) line: 2849
BatchtransferToBatchtransferlineTableForEdit(JTable).process KeyBinding(KeyStroke, KeyEvent, int, boolean) line: 5256
BatchtransferToBatchtransferlineTableForEdit(JTableForEdit). processKeyBinding(KeyStroke, KeyEvent, int, boolean) line: 325
JTextField<T>(JComponent).processKeyBindings(KeyEvent, boolean) line: 2895
JTextField<T>(JComponent).processKeyEvent(KeyEvent) line: 2812
JTextField<T>.processKeyEvent(KeyEvent) line: 449
JTextField<T>(Component).processEvent(AWTEvent) line: 5911
JTextField<T>(Container).processEvent(AWTEvent) line: 2023
JTextField<T>(Component).dispatchEventImpl(AWTEvent) line: 4501
JTextField<T>(Container).dispatchEventImpl(AWTEvent) line: 2081
JTextField<T>(Component).dispatchEvent(AWTEvent) line: 4331
DefaultKeyboardFocusManager(KeyboardFocusManager).redispatch Event(Component, AWTEvent) line: 1848
DefaultKeyboardFocusManager.dispatchKeyEvent(KeyEvent) line: 704
DefaultKeyboardFocusManager.preDispatchKeyEvent(KeyEvent) line: 969
DefaultKeyboardFocusManager.typeAheadAssertions(Component, AWTEvent) line: 841
DefaultKeyboardFocusManager.dispatchEvent(AWTEvent) line: 668
JFrame(Component).dispatchEventImpl(AWTEvent) line: 4373
JFrame(Container).dispatchEventImpl(AWTEvent) line: 2081
JFrame(Window).dispatchEventImpl(AWTEvent) line: 2458
JFrame(Component).dispatchEvent(AWTEvent) line: 4331
EventQueue(EventQueue).dispatchEvent(AWTEvent) line: 599
EventQueue.dispatchEvent(AWTEvent) line: 83
EventDispatchThread.pumpOneEventForFilters(int) line: 269
EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 184
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 174
EventDispatchThread.pumpEvents(int, Conditional) line: 169
EventDispatchThread.pumpEvents(Conditional) line: 161
EventDispatchThread.run() line: 122
Re: PostLoad on a new instance? [message #383037 is a reply to message #383031] Tue, 18 November 2008 14:02 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Not sure I understand, you accessed an existing objects lazy collection,
so it build each object from the database and called the postBuild event?
Which object was new, are you sure your in the postBuild of a new object,
not an existing object?

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: PostLoad on a new instance? [message #383038 is a reply to message #383037] Tue, 18 November 2008 15:26 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
1. I create a new Batchtransferline,
2. then do a JPA query to find an Article
3. assign the Article to that Batchtransferline
4. which causes the Article to load the collection of Batchtransferlines in order to add the newly created one
5. the @PostLoad event is called on the newly created Batchtransferline

I'll see if I can reproduce this as a small test.


James wrote:
> Not sure I understand, you accessed an existing objects lazy collection,
> so it build each object from the database and called the postBuild
> event? Which object was new, are you sure your in the postBuild of a
> new object, not an existing object?
>
> ---
> James
> http://www.nabble.com/EclipseLink---Users-f26658.html
>
Re: PostLoad on a new instance? [message #383040 is a reply to message #383038] Tue, 18 November 2008 15:37 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
OMG. Ehm. I had this whole example setup and it was reproducable. Then I decided to empty the batchtransferline table, just to make sure... And, ah, well. The PostLoad event was on an existing entity. I had used the article already in another.

Shame on me. I'm sorry.
Previous Topic:I must be missing something!
Next Topic:Support for InheritanceType.TABLE_PER_CLASS
Goto Forum:
  


Current Time: Fri Nov 28 17:25:35 GMT 2014

Powered by FUDForum. Page generated in 0.01834 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software