Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dali-dev] Re: help with Dali 2.0 model migration - how do I now get entities?

Tom,

I think you should take a look at JpaProject.Updater and the Synchronous and Asynchronous implementations. For UI development we are using the Asynchronous updater, but since you are doing internal modifications I believe you are going to want the synchronous updater so that when you make context model changes the project is updated before you continue making changes. Also, the code I gave you looks at PersistenceUnit.classRefs() which includes both specifiedClassRefs (those listed directly in the persistence.xml) and impliedClassRefs (those not listed, but that are defaulted in based on your JpaProject 'discovers annotated classes' setting). This is a pardigm we've have followed throughout our context model. I would imagine the problem is because the project Update thread is not completed yet. The update will run, updating our context model from the underlying resources and settings defaults based on other settings in the model. Any change that occurs will cause another run of the update job to be queued up (actually, it will run again once it is finished based on whether any changes have occurred, not for every change that occurs). So, if you used the synchronous project updater, you will not have to worry about there being a separate update thread. In our tests we use the synchronous project updater. I believe this will also solve some of the bugs you have just entered this afternoon.

Hope this helps!

Karen


Tom Mutdosch wrote:

Hi Karen,

I tried the getEntities() code snippet that you had sent me, and it works mostly but does not do exactly what I expected. That seems to only retrieve entities that are listed directly in the persistence.xml file, and not annotated Java entities that aren't explicitly listed. We actually discovered this due to an apparent timing bug where immediately after the Generate Entities wizard was run we called our getEntities() method and it was not returning the new entity classes. (Aside: it looks like there's a separate timing issue here where the entities were not yet updated in the persistence.xml; Is the synchronizeClasses run as a separate Job after GenerateEntities?)

In any case, is there a way to do a similar getEntities() call that gets entities from the Dali model whether they are listed in the persistence.xml or not? It looks like calling jpaProject.annotatedClasses() returns all of the entities as ITypes, so it seems they are stored in the model somehow - I'm just not sure how to appropriately get all of the PersistentTypes.

Thanks
Tom


Karen Moore wrote:

I agree, the code to get a list of entities is a bit convoluted and difficult to find. We've had other adopters ask us for this as well, so documentation on the existing API or helper API is the way to go. Thanks for your feedback!

Karen

Tom Mutdosch wrote:

Hi Karen,

Thanks for the details; I definitely understand all the complexities in providing various API to suit every possible need. I have no problem writing a getEntities() method myself. The main reason I suggested it was that it wasn't totally obvious how to do that using the existing APIs. I figured others might have the same difficulties, so a new API call could address that. But having documentation or examples of how to do some of these common operations would probably help achieve the same effect, so maybe it's not a big deal.

Regarding saving the OrmXML and PersistenceXML models, thanks for the code snippets - that's what I was looking for. I opened an enhancement request with my particular usecase: https://bugs.eclipse.org/bugs/show_bug.cgi?id=223197

Thanks again,
Tom
_______________________________________________
dali-dev mailing list
dali-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dali-dev


_______________________________________________
dali-dev mailing list
dali-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dali-dev


_______________________________________________
dali-dev mailing list
dali-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dali-dev



Back to the top