Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Migration from Dali 2.0 to 2.1
Migration from Dali 2.0 to 2.1 [message #435024] Tue, 02 December 2008 20:06 Go to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
(Reposted from mailing list)

Hello,

I just moved up to Dali 2.1 from Dali 2.0 and ran into a few API changes
that I'm not sure how to fix. I was able to use the wiki page
(http://wiki.eclipse.org/Dali_Provisional_API_Changes) to figure most
things out, but I have questions on a few others.

1. Currently I am using:
JptDbPlugin.instance().getConnectionProfileRepository().conn ectionProfileNamed(profileName);

This returned a ConnectionProfile object. It looks like I'm supposed to
use a ConnectionProfileFactory instead, is the following the best way to
do this:

JptDbPlugin.instance().getConnectionProfileFactory().buildCo nnectionProfile(profileName);


2. Currently I'm doing something like this to get the entity mappings
defined in the orm.xml file.
for (Iterator<MappingFileRef> mappingFiles =
persistenceUnit.mappingFileRefs(); mappingFiles.hasNext();) {
MappingFileRef mappingFileRef = mappingFiles.next();
OrmXml ormXml = mappingFileRef.getOrmXml();
EntityMappings entityMappings = ormXml.getEntityMappings();
}

The following method no longer exists: mappingFileRef.getOrmXml()

I wasn't able to find any information on this change in the wiki page.
Is there a new way I should be handling this situation?


3. I have a bunch of errors around setting and getting Temporal types.
It sounds like I need to use these new ConvertibleMapping objects.
Currently my code looks like this:

((ColumnMapping)mapping).setTemporal(TemporalType.DATE);

and

TemporalType temporalType = ((ColumnMapping)mapping).getTemporal();

I found a few example in your plugins showing how to get TemporalTypes:

if (this.javaIdMapping.getConverter().getType() ==
Converter.TEMPORAL_CONVERTER) {
org.eclipse.jpt.core.context.TemporalType javaTemporalType =
((TemporalConverter) this.javaIdMapping.getConverter()).getTemporalType();
}

Is this the best way to go about finding the TemporalType? I assume if
the mapping has no Temporal_Converter then that means no TemporalType
has been set on the mapping?

I wasn't able to find a good example of setting a Temporal type. Would I
just add a new TemporalConverter to my mapping and then set the value? I
wasn't sure if I could just add a new one because the javadoc in
ConvertibleMapping says calling setSpecifiedConverter(String) will
remove any old converters. Is it safe to do that?


4. Lastly I had been using a class
org.eclipse.jpt.core.context.orm.PersistenceUnitDefaults which no longer
seems to exist. I didn't see anything in the API change doc about this.
Is there something new I should be using instead?


Thanks for your help,
Chris



_______________________________________________
dali-dev mailing list
dali-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/dali-dev
Re: Migration from Dali 2.0 to 2.1 [message #435027 is a reply to message #435024] Tue, 02 December 2008 20:13 Go to previous messageGo to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
> 2. Currently I'm doing something like this to get the entity mappings
> defined in the orm.xml file.
> for (Iterator<MappingFileRef> mappingFiles =
> persistenceUnit.mappingFileRefs(); mappingFiles.hasNext();) {
> MappingFileRef mappingFileRef = mappingFiles.next();
> OrmXml ormXml = mappingFileRef.getOrmXml();
> EntityMappings entityMappings = ormXml.getEntityMappings();
> }
>
> The following method no longer exists: mappingFileRef.getOrmXml()
>
> I wasn't able to find any information on this change in the wiki page.
> Is there a new way I should be handling this situation?

Yes, we need to update the wiki page with quite a lot by the time we
officially release.

But for this particular bit, getOrmXml() has been replaced with
getMappingFile(). In the case that your mapping file is of ORM content
(as opposed to some other platform-specific mapping file), it should
still be an instance of OrmXml.
Re: Migration from Dali 2.0 to 2.1 [message #435029 is a reply to message #435027] Tue, 02 December 2008 20:18 Go to previous messageGo to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
Also ...

> 4. Lastly I had been using a class
> org.eclipse.jpt.core.context.orm.PersistenceUnitDefaults which no longer
> seems to exist. I didn't see anything in the API change doc about this.
> Is there something new I should be using instead?

PersistenceUnitDefaults has been replaced with
org.eclipse.jpt.core.context.MappingFilePersistenceUnitDefau lts,
extended by org.eclipse.jpt.core.context.orm.OrmPersistenceUnitDefaults,
and implemented by
org.eclipse.jpt.core.internal.context.orm.GenericPersistence UnitDefaults


Again, if your mapping file is an orm.xml-type mapping file, the
persistence unit defaults will be an instance of OrmPersistenceUnitDefaults.
Re: Migration from Dali 2.0 to 2.1 [message #435031 is a reply to message #435024] Tue, 02 December 2008 20:44 Go to previous messageGo to next message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 132
Registered: July 2009
Senior Member
> 1. Currently I am using:
> JptDbPlugin.instance().getConnectionProfileRepository().conn ectionProfileNamed(profileName);
>
>
> This returned a ConnectionProfile object. It looks like I'm supposed to
> use a ConnectionProfileFactory instead, is the following the best way to
> do this:
>
> JptDbPlugin.instance().getConnectionProfileFactory().buildCo nnectionProfile(profileName);
>

Yes, it is. Dali used to have one ConnectionProfile per DTP Connection Profile;
but it now has one ConnectionProfile per JPA project. That is, it builds a new
ConnectionProfile for each JPA project, so they are not shared.
Re: Migration from Dali 2.0 to 2.1 [message #435037 is a reply to message #435024] Tue, 02 December 2008 21:24 Go to previous messageGo to next message
Karen Butzke is currently offline Karen ButzkeFriend
Messages: 220
Registered: July 2009
Senior Member
> 3. I have a bunch of errors around setting and getting Temporal types.
> It sounds like I need to use these new ConvertibleMapping objects.
> Currently my code looks like this:

> ((ColumnMapping)mapping).setTemporal(TemporalType.DATE);

> and

> TemporalType temporalType = ((ColumnMapping)mapping).getTemporal();

> I found a few example in your plugins showing how to get TemporalTypes:

> if (this.javaIdMapping.getConverter().getType() ==
> Converter.TEMPORAL_CONVERTER) {
> org.eclipse.jpt.core.context.TemporalType javaTemporalType =
> ((TemporalConverter) this.javaIdMapping.getConverter()).getTemporalType();
> }

> Is this the best way to go about finding the TemporalType? I assume if
> the mapping has no Temporal_Converter then that means no TemporalType
> has been set on the mapping?

Yes, you have found the correct replacement code. Your assumption is
correct except for the invalid case where you have multiple converters
defined on the mapping. Say the user had entered both @Lob and @Temporal,
this is not valid in JPA, and should give a validation error (though we do
not have one defined at the moment). If you look in
GenericJavaBasicMapping.specifiedConverterType(JavaResourceP ersistentAttribute)
you'll see which converter "wins" in this invalid case. I do not remember
the reasoning behind that order, it is probably the order that the
EclipseLink JPA implementation uses, since the JPA spec doesn't define
this.


> I wasn't able to find a good example of setting a Temporal type. Would I
> just add a new TemporalConverter to my mapping and then set the value? I
> wasn't sure if I could just add a new one because the javadoc in
> ConvertibleMapping says calling setSpecifiedConverter(String) will
> remove any old converters. Is it safe to do that?

((ConvertibleMapping)mapping).setSpecifiedConverter(Converte r.TEMPORAL_CONVERTER);
((TemporalConverter)convertibleMapping.getSpecifiedConverter ()).setTemporalType(TemporalType.Date)


This is the correct replacement for this code. Temporal, Lob, Enumerated
are all mutually exclusive in the JPA spec so if you call
setSpecifiedConverter all it is doing is removing the Lob or Enumerated,
if they exist. If your source code was originally in a valid state, only
one converter annotation, it will leave it in that valid state by removing
the old converter annotation and adding the new. If it was already in an
invalid state, then it will still be in an invalid state since only 1 of
the converter annotations will be removed and the new one will be added.
Re: Migration from Dali 2.0 to 2.1 [message #435039 is a reply to message #435024] Tue, 02 December 2008 21:53 Go to previous messageGo to next message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
Much thanks to Paul, Brian, and Karen for help with the migration issues.
I am now compile error free! :-)

Thanks,
Chris
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435043 is a reply to message #435024] Fri, 05 December 2008 15:11 Go to previous messageGo to next message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
Hello,

Another migration questions...

I have something like this:

private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
OrmResource ormResource = null;
JpaProject jpaProject = entity.getJpaProject();
IResource resource = entity.getResource();
if ( jpaProject != null && resource != null ) {
JpaFile jpaFile = jpaProject.getJpaFile((IFile) resource);
if ( jpaFile != null ) {
OrmResourceModel model = (OrmResourceModel) jpaFile.getResourceModel();
if ( model != null ) {
ormResource = model.getResource();
}
}
}
return ormResource;
}
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435045 is a reply to message #435043] Fri, 05 December 2008 15:15 Go to previous messageGo to next message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
Opps...hit submit to soon:

As I was saying I have something like this...

private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
OrmResource ormResource = null;
JpaProject jpaProject = entity.getJpaProject();
IResource resource = entity.getResource();
if ( jpaProject != null && resource != null ) {
JpaFile jpaFile = jpaProject.getJpaFile((IFile) resource);
if ( jpaFile != null ) {
OrmResourceModel model = (OrmResourceModel) jpaFile.getResourceModel();
if ( model != null ) {
ormResource = model.getResource();
}
}
}
return ormResource;
}

Now OrmResourceModel no longer exists and either does getResourceModel on
the JpaFile class.

Is there still a way for me to get the OrmResource object starting from an
OrmPersistentType? Maybe there's a simpler way from what I was doing
before.

Thanks,
Chris
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435046 is a reply to message #435045] Fri, 05 December 2008 17:44 Go to previous messageGo to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
Chris Jaun wrote:

> Opps...hit submit to soon:

> As I was saying I have something like this...

> private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
> OrmResource ormResource = null;
> JpaProject jpaProject = entity.getJpaProject();
> IResource resource = entity.getResource();
> if ( jpaProject != null && resource != null ) {
> JpaFile jpaFile = jpaProject.getJpaFile((IFile) resource);
> if ( jpaFile != null ) {
> OrmResourceModel model = (OrmResourceModel) jpaFile.getResourceModel();
> if ( model != null ) {
> ormResource = model.getResource();
> }
> }
> }
> return ormResource;
> }

> Now OrmResourceModel no longer exists and either does getResourceModel on
> the JpaFile class.

> Is there still a way for me to get the OrmResource object starting from an
> OrmPersistentType? Maybe there's a simpler way from what I was doing
> before.

> Thanks,
> Chris


Slighly easier, yes. :)

private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
return (OrmResource) entity.getEResource();
}
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435047 is a reply to message #435046] Fri, 05 December 2008 19:11 Go to previous messageGo to next message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
That is easier. Thanks Paul!

Chris
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435048 is a reply to message #435047] Fri, 05 December 2008 20:35 Go to previous messageGo to next message
Leonard Theivendra is currently offline Leonard TheivendraFriend
Messages: 36
Registered: July 2009
Member
Hi Paul, given a JpaFile instance for persistence.xml or orm.xml, what is
the recommended way to get a PersistenceResource or OrmResource model in
2.1 please?

I see PersistenceResourceModelProvider.getModelProvider(IFile) and
OrmResourceModelProvider.getModelProvider(IFile) but they seem to be in an
internal package?

Thanks,
Len.
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435049 is a reply to message #435048] Fri, 05 December 2008 22:04 Go to previous messageGo to next message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
Leonard Theivendra wrote:

> Hi Paul, given a JpaFile instance for persistence.xml or orm.xml, what is
> the recommended way to get a PersistenceResource or OrmResource model in
> 2.1 please?

> I see PersistenceResourceModelProvider.getModelProvider(IFile) and
> OrmResourceModelProvider.getModelProvider(IFile) but they seem to be in an
> internal package?

> Thanks,
> Len.

Hi Len,

Can you give me a better idea of what it is you're trying to do? Are you
needing to get here from a JpaFile, or is that the only convenient handle
you have at the moment?

The resource model providers were intended to replace the artifact edits,
and I was pretty sure I put them in the same package, but I could be
mistaken. At any rate, while not officially (or provisionally) API, they
should be safe to use in that they'll do what you want them to, but they
may not be promoted to actual API in the next release. We're still
looking at what kind of API people need at this level, so any information
you can give us will help us provide what's needed.

Thanks,
- Paul
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435050 is a reply to message #435049] Fri, 05 December 2008 22:33 Go to previous messageGo to next message
Leonard Theivendra is currently offline Leonard TheivendraFriend
Messages: 36
Registered: July 2009
Member
Hi Paul, basically given an IProject, we need to get at the file handles
and models for the persistence.xml and orm xml file(s).

So far we've been using JpaModelManager.instance().getJpaProject(IProject)
to get the JpaProject (JpaModelManager is in an internal package too).
From there we use JpaProject.jpaFiles(String) to get the JpaFile handles
to persistence or orm xml files. Due to recent 2.1 changes looks like we
have to do our own filtering using JpaProject.jpaFiles() since
JpaProject.jpaFiles(String) is no longer?

In any case, from the JpaFile handles we've been getting at the models via
getResourceModel() which is now removed in 2.1.

These are some of the APIs we currently use.. I can get back to you with a
more complete list to give you an idea of API usage.

Thanks,
Len.
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #435114 is a reply to message #435050] Mon, 08 December 2008 18:50 Go to previous message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 132
Registered: July 2009
Senior Member
The public API for getting the JpaProject associated with an IProject
is JptCorePlugin.getJpaProject(IProject) (as opposed to the call you are
making to JpaModelManager).

You could reach the persistence.xml and orm.xml resources a bit more
semantically via the Dali "context" model:

JpaProject.getRootContextNode().getPersistenceXml().getEReso urce()

and (roughly):

JpaProject.getRootContextNode().getPersistenceXml().getPersi stence()
.persistenceUnits().mappingFileRefs().getMappingFile().getXm lResource()

The JpaFiles are probably going to become "internal" state to the JpaProject
in the near future. The hope being that you could get what you need via the
context model. Is there something not provided by the context model that you
need?

Leonard Theivendra wrote:
> Hi Paul, basically given an IProject, we need to get at the file handles
> and models for the persistence.xml and orm xml file(s).
> So far we've been using
> JpaModelManager.instance().getJpaProject(IProject) to get the JpaProject
> (JpaModelManager is in an internal package too). From there we use
> JpaProject.jpaFiles(String) to get the JpaFile handles to persistence or
> orm xml files. Due to recent 2.1 changes looks like we have to do our
> own filtering using JpaProject.jpaFiles() since
> JpaProject.jpaFiles(String) is no longer?
>
> In any case, from the JpaFile handles we've been getting at the models
> via getResourceModel() which is now removed in 2.1.
>
> These are some of the APIs we currently use.. I can get back to you with
> a more complete list to give you an idea of API usage.
>
> Thanks,
> Len.
>
Re: Migration from Dali 2.0 to 2.1 [message #613105 is a reply to message #435024] Tue, 02 December 2008 20:13 Go to previous message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
> 2. Currently I'm doing something like this to get the entity mappings
> defined in the orm.xml file.
> for (Iterator<MappingFileRef> mappingFiles =
> persistenceUnit.mappingFileRefs(); mappingFiles.hasNext();) {
> MappingFileRef mappingFileRef = mappingFiles.next();
> OrmXml ormXml = mappingFileRef.getOrmXml();
> EntityMappings entityMappings = ormXml.getEntityMappings();
> }
>
> The following method no longer exists: mappingFileRef.getOrmXml()
>
> I wasn't able to find any information on this change in the wiki page.
> Is there a new way I should be handling this situation?

Yes, we need to update the wiki page with quite a lot by the time we
officially release.

But for this particular bit, getOrmXml() has been replaced with
getMappingFile(). In the case that your mapping file is of ORM content
(as opposed to some other platform-specific mapping file), it should
still be an instance of OrmXml.
Re: Migration from Dali 2.0 to 2.1 [message #613106 is a reply to message #435027] Tue, 02 December 2008 20:18 Go to previous message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
Also ...

> 4. Lastly I had been using a class
> org.eclipse.jpt.core.context.orm.PersistenceUnitDefaults which no longer
> seems to exist. I didn't see anything in the API change doc about this.
> Is there something new I should be using instead?

PersistenceUnitDefaults has been replaced with
org.eclipse.jpt.core.context.MappingFilePersistenceUnitDefau lts,
extended by org.eclipse.jpt.core.context.orm.OrmPersistenceUnitDefaults,
and implemented by
org.eclipse.jpt.core.internal.context.orm.GenericPersistence UnitDefaults


Again, if your mapping file is an orm.xml-type mapping file, the
persistence unit defaults will be an instance of OrmPersistenceUnitDefaults.
Re: Migration from Dali 2.0 to 2.1 [message #613109 is a reply to message #435024] Tue, 02 December 2008 20:44 Go to previous message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 132
Registered: July 2009
Senior Member
> 1. Currently I am using:
> JptDbPlugin.instance().getConnectionProfileRepository().conn ectionProfileNamed(profileName);
>
>
> This returned a ConnectionProfile object. It looks like I'm supposed to
> use a ConnectionProfileFactory instead, is the following the best way to
> do this:
>
> JptDbPlugin.instance().getConnectionProfileFactory().buildCo nnectionProfile(profileName);
>

Yes, it is. Dali used to have one ConnectionProfile per DTP Connection Profile;
but it now has one ConnectionProfile per JPA project. That is, it builds a new
ConnectionProfile for each JPA project, so they are not shared.
Re: Migration from Dali 2.0 to 2.1 [message #613113 is a reply to message #435024] Tue, 02 December 2008 21:24 Go to previous message
Karen Butzke is currently offline Karen ButzkeFriend
Messages: 220
Registered: July 2009
Senior Member
> 3. I have a bunch of errors around setting and getting Temporal types.
> It sounds like I need to use these new ConvertibleMapping objects.
> Currently my code looks like this:

> ((ColumnMapping)mapping).setTemporal(TemporalType.DATE);

> and

> TemporalType temporalType = ((ColumnMapping)mapping).getTemporal();

> I found a few example in your plugins showing how to get TemporalTypes:

> if (this.javaIdMapping.getConverter().getType() ==
> Converter.TEMPORAL_CONVERTER) {
> org.eclipse.jpt.core.context.TemporalType javaTemporalType =
> ((TemporalConverter) this.javaIdMapping.getConverter()).getTemporalType();
> }

> Is this the best way to go about finding the TemporalType? I assume if
> the mapping has no Temporal_Converter then that means no TemporalType
> has been set on the mapping?

Yes, you have found the correct replacement code. Your assumption is
correct except for the invalid case where you have multiple converters
defined on the mapping. Say the user had entered both @Lob and @Temporal,
this is not valid in JPA, and should give a validation error (though we do
not have one defined at the moment). If you look in
GenericJavaBasicMapping.specifiedConverterType(JavaResourceP ersistentAttribute)
you'll see which converter "wins" in this invalid case. I do not remember
the reasoning behind that order, it is probably the order that the
EclipseLink JPA implementation uses, since the JPA spec doesn't define
this.


> I wasn't able to find a good example of setting a Temporal type. Would I
> just add a new TemporalConverter to my mapping and then set the value? I
> wasn't sure if I could just add a new one because the javadoc in
> ConvertibleMapping says calling setSpecifiedConverter(String) will
> remove any old converters. Is it safe to do that?

((ConvertibleMapping)mapping).setSpecifiedConverter(Converte r.TEMPORAL_CONVERTER);
((TemporalConverter)convertibleMapping.getSpecifiedConverter ()).setTemporalType(TemporalType.Date)


This is the correct replacement for this code. Temporal, Lob, Enumerated
are all mutually exclusive in the JPA spec so if you call
setSpecifiedConverter all it is doing is removing the Lob or Enumerated,
if they exist. If your source code was originally in a valid state, only
one converter annotation, it will leave it in that valid state by removing
the old converter annotation and adding the new. If it was already in an
invalid state, then it will still be in an invalid state since only 1 of
the converter annotations will be removed and the new one will be added.
Re: Migration from Dali 2.0 to 2.1 [message #613115 is a reply to message #435024] Tue, 02 December 2008 21:53 Go to previous message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
Much thanks to Paul, Brian, and Karen for help with the migration issues.
I am now compile error free! :-)

Thanks,
Chris
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613119 is a reply to message #435024] Fri, 05 December 2008 15:11 Go to previous message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
Hello,

Another migration questions...

I have something like this:

private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
OrmResource ormResource = null;
JpaProject jpaProject = entity.getJpaProject();
IResource resource = entity.getResource();
if ( jpaProject != null && resource != null ) {
JpaFile jpaFile = jpaProject.getJpaFile((IFile) resource);
if ( jpaFile != null ) {
OrmResourceModel model = (OrmResourceModel) jpaFile.getResourceModel();
if ( model != null ) {
ormResource = model.getResource();
}
}
}
return ormResource;
}
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613122 is a reply to message #435043] Fri, 05 December 2008 15:15 Go to previous message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
Opps...hit submit to soon:

As I was saying I have something like this...

private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
OrmResource ormResource = null;
JpaProject jpaProject = entity.getJpaProject();
IResource resource = entity.getResource();
if ( jpaProject != null && resource != null ) {
JpaFile jpaFile = jpaProject.getJpaFile((IFile) resource);
if ( jpaFile != null ) {
OrmResourceModel model = (OrmResourceModel) jpaFile.getResourceModel();
if ( model != null ) {
ormResource = model.getResource();
}
}
}
return ormResource;
}

Now OrmResourceModel no longer exists and either does getResourceModel on
the JpaFile class.

Is there still a way for me to get the OrmResource object starting from an
OrmPersistentType? Maybe there's a simpler way from what I was doing
before.

Thanks,
Chris
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613124 is a reply to message #435045] Fri, 05 December 2008 17:44 Go to previous message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
Chris Jaun wrote:

> Opps...hit submit to soon:

> As I was saying I have something like this...

> private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
> OrmResource ormResource = null;
> JpaProject jpaProject = entity.getJpaProject();
> IResource resource = entity.getResource();
> if ( jpaProject != null && resource != null ) {
> JpaFile jpaFile = jpaProject.getJpaFile((IFile) resource);
> if ( jpaFile != null ) {
> OrmResourceModel model = (OrmResourceModel) jpaFile.getResourceModel();
> if ( model != null ) {
> ormResource = model.getResource();
> }
> }
> }
> return ormResource;
> }

> Now OrmResourceModel no longer exists and either does getResourceModel on
> the JpaFile class.

> Is there still a way for me to get the OrmResource object starting from an
> OrmPersistentType? Maybe there's a simpler way from what I was doing
> before.

> Thanks,
> Chris


Slighly easier, yes. :)

private static OrmResource getOrmXMLResource(OrmPersistentType entity) {
return (OrmResource) entity.getEResource();
}
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613125 is a reply to message #435046] Fri, 05 December 2008 19:11 Go to previous message
Chris Jaun is currently offline Chris JaunFriend
Messages: 17
Registered: July 2009
Junior Member
That is easier. Thanks Paul!

Chris
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613127 is a reply to message #435047] Fri, 05 December 2008 20:35 Go to previous message
Leonard Theivendra is currently offline Leonard TheivendraFriend
Messages: 36
Registered: July 2009
Member
Hi Paul, given a JpaFile instance for persistence.xml or orm.xml, what is
the recommended way to get a PersistenceResource or OrmResource model in
2.1 please?

I see PersistenceResourceModelProvider.getModelProvider(IFile) and
OrmResourceModelProvider.getModelProvider(IFile) but they seem to be in an
internal package?

Thanks,
Len.
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613129 is a reply to message #435048] Fri, 05 December 2008 22:04 Go to previous message
Paul Fullbright is currently offline Paul FullbrightFriend
Messages: 200
Registered: July 2009
Senior Member
Leonard Theivendra wrote:

> Hi Paul, given a JpaFile instance for persistence.xml or orm.xml, what is
> the recommended way to get a PersistenceResource or OrmResource model in
> 2.1 please?

> I see PersistenceResourceModelProvider.getModelProvider(IFile) and
> OrmResourceModelProvider.getModelProvider(IFile) but they seem to be in an
> internal package?

> Thanks,
> Len.

Hi Len,

Can you give me a better idea of what it is you're trying to do? Are you
needing to get here from a JpaFile, or is that the only convenient handle
you have at the moment?

The resource model providers were intended to replace the artifact edits,
and I was pretty sure I put them in the same package, but I could be
mistaken. At any rate, while not officially (or provisionally) API, they
should be safe to use in that they'll do what you want them to, but they
may not be promoted to actual API in the next release. We're still
looking at what kind of API people need at this level, so any information
you can give us will help us provide what's needed.

Thanks,
- Paul
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613131 is a reply to message #435049] Fri, 05 December 2008 22:33 Go to previous message
Leonard Theivendra is currently offline Leonard TheivendraFriend
Messages: 36
Registered: July 2009
Member
Hi Paul, basically given an IProject, we need to get at the file handles
and models for the persistence.xml and orm xml file(s).

So far we've been using JpaModelManager.instance().getJpaProject(IProject)
to get the JpaProject (JpaModelManager is in an internal package too).
From there we use JpaProject.jpaFiles(String) to get the JpaFile handles
to persistence or orm xml files. Due to recent 2.1 changes looks like we
have to do our own filtering using JpaProject.jpaFiles() since
JpaProject.jpaFiles(String) is no longer?

In any case, from the JpaFile handles we've been getting at the models via
getResourceModel() which is now removed in 2.1.

These are some of the APIs we currently use.. I can get back to you with a
more complete list to give you an idea of API usage.

Thanks,
Len.
Re: Migration from Dali 2.0 to 2.1 - OrmResourceModel [message #613670 is a reply to message #435050] Mon, 08 December 2008 18:50 Go to previous message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 132
Registered: July 2009
Senior Member
The public API for getting the JpaProject associated with an IProject
is JptCorePlugin.getJpaProject(IProject) (as opposed to the call you are
making to JpaModelManager).

You could reach the persistence.xml and orm.xml resources a bit more
semantically via the Dali "context" model:

JpaProject.getRootContextNode().getPersistenceXml().getEReso urce()

and (roughly):

JpaProject.getRootContextNode().getPersistenceXml().getPersi stence()
.persistenceUnits().mappingFileRefs().getMappingFile().getXm lResource()

The JpaFiles are probably going to become "internal" state to the JpaProject
in the near future. The hope being that you could get what you need via the
context model. Is there something not provided by the context model that you
need?

Leonard Theivendra wrote:
> Hi Paul, basically given an IProject, we need to get at the file handles
> and models for the persistence.xml and orm xml file(s).
> So far we've been using
> JpaModelManager.instance().getJpaProject(IProject) to get the JpaProject
> (JpaModelManager is in an internal package too). From there we use
> JpaProject.jpaFiles(String) to get the JpaFile handles to persistence or
> orm xml files. Due to recent 2.1 changes looks like we have to do our
> own filtering using JpaProject.jpaFiles() since
> JpaProject.jpaFiles(String) is no longer?
>
> In any case, from the JpaFile handles we've been getting at the models
> via getResourceModel() which is now removed in 2.1.
>
> These are some of the APIs we currently use.. I can get back to you with
> a more complete list to give you an idea of API usage.
>
> Thanks,
> Len.
>
Previous Topic:API changes in recent Dali 2.1 builds
Next Topic:Join Table cannot be resolved
Goto Forum:
  


Current Time: Wed Nov 26 18:53:36 GMT 2014

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

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