Auto-mapping in Toplink
how can TopLink's auto-mapping feature be coded if my application was deployed as a Java project?
the mapping information/descriptors (and all that) are in a java file. I am about to add 2 new fields to my database table, and would like to use TopLink's auto-map feature. Problem is, I don't have the workbench GUI interface.
I have instructions (thanks to Don) on how to map by hand-coding, but if there is a setting that I can code, say a one-liner or so, that would be great.
I think there is a misunderstanding as to what a persistence layer is and does... To update your application with new state, you need to first update your object model (has nothing to do with TopLink), then your application (again, nothing to do with TopLink), and then your mappings and persistence layer code (has to do with TopLink). There is no magic here.
Auto-mapping is a feature in the Mapping Workbench to do much of the tedious O-R mapping automatically. It does not automatically keep your application up to date with schema chages.
- Don
Similar Messages
-
Hi All,
I am working on XSLT in 10g(10.1.3.4), Also I would like to use auto-map option available in Jdev.
currently mapping is done as below,
<ProductName>
<xsl:value-of select="ProductName"/>
</ProductName>
But I would need each node encapsulated with xsl:if, so that epmty node will not present in output doc.
ExampleWith xsl:If
<xsl:if test="ProductName">
<ProductName>
<xsl:value-of select="ProductName"/>
</ProductName>
</xsl:if>
is this auto option is available in 10g?
Please help me to achieve this in 10 g XSLT.
thanks,
SantoshI think there is a misunderstanding as to what a persistence layer is and does... To update your application with new state, you need to first update your object model (has nothing to do with TopLink), then your application (again, nothing to do with TopLink), and then your mappings and persistence layer code (has to do with TopLink). There is no magic here.
Auto-mapping is a feature in the Mapping Workbench to do much of the tedious O-R mapping automatically. It does not automatically keep your application up to date with schema chages.
- Don -
Issue with Update Rollup 5 for Exchange 2010 SP3 - Mailboxes that were auto mapped not working
Below is my response in another thread but creating a new one in the hopes that someone has the same issue and a solution besides mine below.
Ever since we installed Update Rollup 5 for SP3 Exchange 2010 mailboxes that were auto mapped are not accessible. They all get the same error.
Cannot expand the folder. The set of folders cannot be opened. The attempt to log on to the Microsoft Exchange has failed.
What I have been doing is removing the users permission, then adding them back using the noautomap switch in Powershell. After doing that, the user manually adds the mailbox and all is well.
Just a note here, I suspect it may have something to do with the version of Outlook 2010. We are running an older version here. I think only SP1 with no other incremental updates. Office is up to SP2. Also, one of the users I was working with could not access
the mailbox no matter what we tried but she can walk over to another workstation and open Outlook and access the very same mailbox so that pretty much proves its software related particularly with Outlook.
I cannot reproduce the problem on a workstation (XP) with a newer version of Outlook.
This has been wearing me out and I suspected the Update Rollup all long. Now I am confident as others are having the same problem. If you find out anything on how to fix this other than the steps above, let me know.Not sure why it was suggested to use the auto mapping feature to grant permissions because that is the component that is causing the issue. Also, there is nothing wrong with the auto configuration because the user can access their own mailbox just fine and
also select mailboxes in their Outlook that were NOT auto mapped.
With that said, here is how I fixed them all.
Remove the permissions using the Exchange Console. Don't forget Send As
Wait about 15 minutes. The mailbox should disappear from the users Outlook
Open an Exchange PowerShell window and run the following command:
.\add-mailboxpermissionsnoautomap.ps1 -Identity mailbox -User user -AccessRights FullAccess
Have the user add the mailbox to their Outlook using the manual process.
All is well....
If you don't have the PS script add-mailboxpermissionsnoautomap.ps1, you can download it. I stumbled across it a few years ago and use it all the time. If you can't find it, just use the Exchange built in command for adding mailbox folder permissions but
specify automap $false.
The idea here is to grant the user access without auto mapping. -
Exchange 2010 Auto-Mapping not removing mailbox from Outlook
I am having an issue that others seem to have as well. When I give Full Access to another mailbox, auto-mapping brings it in to the users Outlook 2010 client. However, when I remove that users access to the shared mailbox it doesn't remove the
mailbox from Outlook.
I know that I can go the shared account in ADSIedit and edit the msExchDelegateListLink and remove the user that should no longer have access, but this is not a good solution. I feel this is a bug that Microsoft should address and release a patch for.
Does anyone know of a fix? Not a workaround, an actual fix?Hi,
Based on my experience, we can take the following actions to remove the additional mailbox :
1. Turn off the auto-mapping feature for your account:
Add-MailboxPermission usermailbox –user PersonBeingGrantedRights –AccessRights ‘FullAccess’ –AutoMapping:$false
2. Remove the full access permission by using EMC or EMS.
3. Clear the msExchDelegateListLink attribute for all mailboxes which are being displayed as an additional mailbox in Outlook. In your case, you need change 10 msExchDelegateListLink attributes.
If you have any question, please feel free to let me know.
Thanks,
Angela
Angela Shi
TechNet Community Support -
Auto-Mapping Exchange 2013 Mailboxs in an Exchange 2010 Mailbox
We're in the middle of migrating mailboxes from Exchange 2010 to Exchange 2013. Many of our users have Auto-Mapped mailboxes as well. In my testing, I've found that I cannot Auto-Map a mailbox that's on Exchange 2013 in a Exchange 2010 mailbox. I can manually
add it and it works fine. Is this by design with this type of coexistence or is there a fix for it? Our current Exchange 2010 environment is at SP3 with UR2.
Orange County District AttorneyThis issues is fixed in UR5 so suggest you to upgrade Exchange 2010 to SP3 UR5.
Reference Thread: http://social.technet.microsoft.com/Forums/exchange/en-US/a2aa4163-f74b-401f-aec5-13324e6b29c8/exchange-2010-mailbox-not-able-to-access-automapped-exchange-2013-cu3-mailbox?forum=exchangesvradmin
Blog |
Get Your Exchange Powershell Tip of the Day from here -
Auto-mapping of shared mailboxes in a resource forest scenario
In a resource forest scenario you assign full access to a shared mailbox using:
Add-MailboxPermission -Identity SharedMailbox -User AccountForestDomain\UserID -AccessRights FullAccess
This provides the user in the account forest full access, but it will NOT auto-map the shared mailbox in Outlook.
If you use the command:
Add-MailboxPermission -Identity SharedMailbox -User UserID -AccessRights FullAccess
and UserID is the disabled account of the linked mailbox in the resource forest then the user in the account forest does not have the necessary permission to
open the mailbox, but the auto-mapping of the mailbox in Outlook works.
You have to use both commands to have the auto-mapping feature and have access to the shared mailbox.
This looks like another issue of the auto-mapping feature. The intention of the feature is good, but the way it was implemented can be improved.
How do you configure full access to shared mailboxes in a resource forest scenario?Hi J-H,
Because i don’t have such a lab environment, so I am unable to do a test.
Now let’s separate the issue.
1. The first issue is
[email protected]
unable to auto configure outlook profile.
I suggest you
changing the user’s attributes in the account forest, does it work?
2. The second issue is
[email protected] unable to open a shared mailbox in the resource
forest.
At first, I suggest you create a shared mailbox in resource forest with this command.
New-Mailbox -name
<name> -Database <Database name> -OrganizationalUnit Users –UserPrincipalName
<UPN value, example: [email protected]> -<ResourceType: Room, Equipment or Shared>
Managing
Resource Mailboxes in Exchange Server 2007 (Part 1)
Then test if you can log on the shared mailbox via outlook.
If yes, then grant full access right for
[email protected]
to [email protected]
Resource:
Shared mailbox
permission in resource forest with linked users
Manage Full Access Permissions
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
Exceptions while Opening a older toplink map in toplink 11g workbench
Hi
I have a toplink map used with toplink 10g. Now that after moving to toplink 11g I am unable to open the map using workbench. I am getting the following exception while opening.
Inputs to solve this probelm are welcomed.
oracle.toplink.workbench.framework.OpenException: Exception [TOPLINK-106] (Oracle TopLink - 11g (11.1.1.0.1) (Build 081030)): oracle.toplink.exceptions.DescriptorException
Exception Description: The method [legacySetDatabasePlatformNameForTopLink] on the object is throwing an exception.
Argument: [null]
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.IllegalArgumentException: missing database platform named: null
Mapping: oracle.toplink.mappings.DirectToFieldMapping[databasePlatformName-->platform-name]
Descriptor: XMLDescriptor(oracle.toplink.workbench.mappingsmodel.db.MWDatabase --> [DatabaseTable(database)])
at oracle.toplink.workbench.mappingsplugin.MappingsPlugin.open(MappingsPlugin.java:293)
at oracle.toplink.workbench.framework.internal.FrameworkApplication.open(FrameworkApplication.java:689)
at oracle.toplink.workbench.framework.internal.FrameworkNodeManager.openCallback(FrameworkNodeManager.java:341)
at oracle.toplink.workbench.framework.internal.RunnableProjectLoader.run2(RunnableProjectLoader.java:76)
at oracle.toplink.workbench.framework.internal.RunnableProjectLoader.run(RunnableProjectLoader.java:63)
at java.lang.Thread.run(Thread.java:595)
Caused by: Exception [TOPLINK-106] (Oracle TopLink - 11g (11.1.1.0.1) (Build 081030)): oracle.toplink.exceptions.DescriptorException
Exception Description: The method [legacySetDatabasePlatformNameForTopLink] on the object is throwing an exception.
Argument: [null]
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.IllegalArgumentException: missing database platform named: null
Mapping: oracle.toplink.mappings.DirectToFieldMapping[databasePlatformName-->platform-name]
Descriptor: XMLDescriptor(oracle.toplink.workbench.mappingsmodel.db.MWDatabase --> [DatabaseTable(database)])
at oracle.toplink.exceptions.DescriptorException.targetInvocationWhileSettingValueThruMethodAccessor(DescriptorException.java:1702)
at oracle.toplink.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:202)
at oracle.toplink.mappings.DatabaseMapping.setAttributeValueInObject(DatabaseMapping.java:1228)
at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1118)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:277)
at oracle.toplink.sdk.SDKAggregateObjectMapping.buildCompositeObject(SDKAggregateObjectMapping.java:58)
at oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping.valueFromRow(AbstractCompositeObjectMapping.java:231)
at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1117)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:277)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:582)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:439)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:389)
at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:511)
at oracle.toplink.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:433)
at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:397)
at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2260)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1074)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1017)
at oracle.toplink.internal.sessions.AbstractSession.readObject(AbstractSession.java:2822)
at oracle.toplink.workbench.mappingsio.legacy.PersistenceTools50.readMWProjectNamed(PersistenceTools50.java:323)
at oracle.toplink.workbench.mappingsio.legacy.LegacyIOFacade.read50Project(LegacyIOFacade.java:21)
at oracle.toplink.workbench.mappingsio.ProjectReader.readLegacyProject(ProjectReader.java:248)
at oracle.toplink.workbench.mappingsio.ProjectReader.read(ProjectReader.java:104)
at oracle.toplink.workbench.mappingsio.ProjectIOManager.read(ProjectIOManager.java:59)
at oracle.toplink.workbench.mappingsplugin.MappingsPlugin.open(MappingsPlugin.java:289)
... 5 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at oracle.toplink.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:174)
at oracle.toplink.mappings.DatabaseMapping.setAttributeValueInObject(DatabaseMapping.java:1228)
at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1118)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:277)
at oracle.toplink.sdk.SDKAggregateObjectMapping.buildCompositeObject(SDKAggregateObjectMapping.java:58)
at oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping.valueFromRow(AbstractCompositeObjectMapping.java:231)
at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1117)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:277)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:582)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:439)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:389)
at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:511)
at oracle.toplink.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:433)
at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:397)
at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2260)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1074)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1017)
at oracle.toplink.internal.sessions.AbstractSession.readObject(AbstractSession.java:2822)
at oracle.toplink.workbench.mappingsio.legacy.PersistenceTools50.readMWProjectNamed(PersistenceTools50.java:323)
at oracle.toplink.workbench.mappingsio.legacy.LegacyIOFacade.read50Project(LegacyIOFacade.java:21)
at oracle.toplink.workbench.mappingsio.ProjectReader.readLegacyProject(ProjectReader.java:248)
at oracle.toplink.workbench.mappingsio.ProjectReader.read(ProjectReader.java:104)
at oracle.toplink.workbench.mappingsio.ProjectIOManager.read(ProjectIOManager.java:59)
Caused by: java.lang.IllegalArgumentException: missing database platform named: null
at oracle.toplink.workbench.platformsmodel.DatabasePlatformRepository.platformNamed(DatabasePlatformRepository.java:334)
at oracle.toplink.workbench.mappingsmodel.db.MWDatabase.setDatabasePlatformNameForTopLink(MWDatabase.java:1013)
at oracle.toplink.workbench.mappingsmodel.db.MWDatabase.legacySetDatabasePlatformNameForTopLink(MWDatabase.java:1133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at oracle.toplink.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:174)
at oracle.toplink.mappings.DatabaseMapping.setAttributeValueInObject(DatabaseMapping.java:1228)
at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1118)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:277)
at oracle.toplink.sdk.SDKAggregateObjectMapping.buildCompositeObject(SDKAggregateObjectMapping.java:58)
at oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping.valueFromRow(AbstractCompositeObjectMapping.java:231)
at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1117)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:277)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:582)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:439)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:389)
at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:511)
at oracle.toplink.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:433)
at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:397)
at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2260)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1074)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1017)
at oracle.toplink.internal.sessions.AbstractSession.readObject(AbstractSession.java:2822)
at oracle.toplink.workbench.mappingsio.legacy.PersistenceTools50.readMWProjectNamed(PersistenceTools50.java:323)
at oracle.toplink.workbench.mappingsio.legacy.LegacyIOFacade.read50Project(LegacyIOFacade.java:21)
at oracle.toplink.workbench.mappingsio.ProjectReader.readLegacyProject(ProjectReader.java:248)
at oracle.toplink.workbench.mappingsio.ProjectReader.read(ProjectReader.java:104)
at oracle.toplink.workbench.mappingsio.ProjectIOManager.read(ProjectIOManager.java:59)
at oracle.toplink.workbench.mappingsplugin.MappingsPlugin.open(MappingsPlugin.java:289)
at oracle.toplink.workbench.framework.internal.FrameworkApplication.open(FrameworkApplication.java:689)
at oracle.toplink.workbench.framework.internal.FrameworkNodeManager.openCallback(FrameworkNodeManager.java:341)
at oracle.toplink.workbench.framework.internal.RunnableProjectLoader.run2(RunnableProjectLoader.java:76)
at oracle.toplink.workbench.framework.internal.RunnableProjectLoader.run(RunnableProjectLoader.java:63)
at java.lang.Thread.run(Thread.java:595)
SreeHi Sree,
If you could email me a copy of the whole mapping workbench project, I can probably fix this issue for you.
Thanks,
Les -
Exchange 2010 mailbox not able to access auto-mapped Exchange 2013 CU3 mailbox
Hi,
We are in co-existence with Exchange 2010 SP3 and Exchange 2013 CU3.
Outlook Anywhere and Autodiscover pointed towards Exchange 2013 CAS servers. Everything works fine irrespective where is mailbox is located Exchange 2010 or 2013.
When I tried to access auto-mapped mailbox from Exchange 2010 as primary mailbox accessing auto-mapped Exchange 2013 mailbox "Cannot expand the folder. The set of folders cannot be opened. Microsoft Exchange is not available. Either there are network
problems or the Exchange server is down for maintenance".
Exchange 2013 OutlookAnywhere "Externalclientauthenticationmethod" is Basic and "Internalclientauthencitcationmethod" is NTLM. Everything is setup as per the Tech-net recommendations.
Checked both these articles but still it is not working:
http://support.microsoft.com/kb/2839517
http://support.microsoft.com/kb/2834139
Please let me know if there are any other ideas.
RamanHi,
I recommend you refer to the following articles to troubleshoot the issue:
Troubleshooting Mailbox Auto-Mapping : Autodiscover
Details about the shared mailbox that is to be accessed will be returned to the Outlook client by the autodiscover process. This is really handy to know if you are ever in the position where you need to troubleshoot why the auto-mapping feature isn’t working
correctly
Troubleshooting Mailbox Auto-Mapping : Permissions
When you use either the Exchange Management Console or the Exchange Management Shell to grant a user with full access permission against another mailbox, permissions changes are made to allow this as you might expect. Certain Active Directory attributes
are also updated to reflect both the Active Directory account of the mailbox being accessed as well as the Active Directory account of the accessing mailbox. Specifically, you can check the contents of the msExchDelegateListLink and msExchDelegateListBL Active
Directory attributes to see these details and it is worth checking these if you have any suspicions that things aren’t working correctly.
Hope this helps!
Thanks.
Niko Cheng
TechNet Community Support -
Let Auto-Map in Transform work with COLLAPSED nodes/tags ?
When I open for a "Transform" activity the mapping editor and drag one complextype from one side to another on the other side then Auto-Mapping only works if the node/tag trees on both elements/sides are full expanded.
If they are collapsed then auto-map does (currently) not work.
Is there a way (option) to tell JDeveloper to look INSIDE collapsed nodes/trees and to auto-map the elements anyway?
PeterHi,
Have you checked if the "outside" ACL is getting hitcounts?
Could also be usefull to check the logs through ASDM monitoring and see what happens when you attempt the connection.
The NAT configurations seem correct to me.
Have you tried to test the connections by briefly allowing all traffic from outside? (Since the only place people could connect to is the forwarded ports.) Have you tried to add the current DHCP IP of "outside" to the ACL and see if it makes any difference?
If no configuration change makes a difference I would suggest using the ASDM monitoring to take logs of what happens.
You could also use the "packet-tracer" command
Format is
packet-tracer input outside tcp
And copy/paste the output here.
- Jouni -
JPA OneToMany mapping whit toplink...
I have a problem when i want to map a OneToMany unidirectional relation using toplink. Toplink maps the relation as a ManyToMany relation instead?
Code in a class called Car:
@OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE})
public List<Wheel> getWheels() { return wheels; }
public void setWheels(List<Wheel> wheels) { this.wheels = wheels; }
toplink output:
[TopLink Config]: 2006.11.07 11:41:41.984--ServerSession(9505840)--The target entity (reference) class for the one to many mapping element [public java.util.List entities.Car.getWheels()] is being defaulted to: class entities.Wheel.
[TopLink Config]: 2006.11.07 11:41:41.984--ServerSession(9505840)--The join table name for the many to many mapping [public java.util.List entities.Car.getWheels()] is being defaulted to: CAR_WHEEL.
[TopLink Config]: 2006.11.07 11:41:41.984--ServerSession(9505840)--The source primary key column name for the many to many mapping [public java.util.List entities.Car.getWheels()] is being defaulted to: CARID.
[TopLink Config]: 2006.11.07 11:41:41.984--ServerSession(9505840)--The source foreign key column name for the many to many mapping [public java.util.List entities.Car.getWheels()] is being defaulted to: Car_CARID.
[TopLink Config]: 2006.11.07 11:41:41.984--ServerSession(9505840)--The target primary key column name for the many to many mapping [public java.util.List entities.Car.getWheels()] is being defaulted to: WHEELID.
[TopLink Config]: 2006.11.07 11:41:41.984--ServerSession(9505840)--The target foreign key column name for the many to many mapping [public java.util.List entities.Car.getWheels()] is being defaulted to: wheels_WHEELID.
When i use @JoinColumn i get a message from toplink that says that it is not required when the relation is unidirectional so it is not possible to identify the foreign key..The JPA Spec does not allow unidirectional 1-m relationships without using a join table, they must always be bidirectional. You must define a 1-1 back-reference and use the "mapped-by" in the 1-m mapping referencing the 1-1.
-
ObjectRelational Mapping with Toplink
Hi,
I'm looking for any tutorial or example about ObjectRelational mappings, Object-types, Varrays, Nested tables, ObjectRelationalDescriptor. I tried with code examples from b100063,b100064. but they are too short and not clear.
thanks,Hi,
I found this example on metalink.oracle.com it gives a good example of a Varray. I tried the example and it works. You said that there were code examples: b100063,b100064, where are they located.
Anyway here is the example:
Bookmark Fixed font Go to End
Doc ID: Note:224177.1
Subject: Mapping to a VARRAY object type defined in an Oracle database
Type: SAMPLE CODE
Status: PUBLISHED
Content Type: TEXT/PLAIN
Creation Date: 20-DEC-2002
Last Revision Date: 08-APR-2003
Overview
Oracle9iAS TopLink supports object-relational mapping. That means that
custom made datatypes (created by developer) in database could be used
to map some java application side attributes to. One of object types is
VARRAY. Mapping Workbench does not allow object-relational mapping (at
the time when this article is written), but if this feature is needed,
project file can be edited to accomplish this.
If object type (VARRAY) already exist in database, all developer has to
do is make TopLink aware of it and map an attribute to it.
Program Notes
This example uses varray type courses_list_type defined in oracle database as:
create or replace type courses_list_type as varray(5) of varchar2(25);
The courses_list_type type is used in table test_student (used in this example)
defined as:
create TABLE test_student (
student_id number(3) PRIMARY KEY,
student_name varchar2(30),
student_courses courses_list_type);
Since we need some data in table test_student, the following statement has
been executed:
INSERT INTO test_student VALUES(1, 'Ron More',
courses_list_type ('Visual Basic', 'Java', 'C++', 'UML', 'SQL'));
Caution
The sample program in this article is provided for educational purposes only
and is NOT supported by Oracle Support Services. It has been tested
internally, however, and works as documented. We do not guarantee that it
will work for you, so be sure to test it in your environment before relying
on it.
Program
SessionEventAdapter class must be set up and the preLogin() method implemented.
The session can be retrieved from the SessionEvent (getSession() method) and
descriptor with the VARRAY MAPPING (the new ObjectRelationalDescriptor) added
to the project. This must be done in code since this cannot be done from the
Mapping Workbench. This is recommended way of dealing with this issue since
the modification of the project.java (generated by Mapping Workbench) file is
avoided. Doing this, project itself can be modified many times without changing
object-relational descriptor.
A) class Student is created in Jdeveloper
package oracle.toplink.demos.employee.domain;
import java.util.*;
import java.io.*;
public class Student {
private int id;
private String name; // a collection of courses being stored in Oracle database as VArray type
private Vector courses;
public Student ( ){
this.id = 0;
this.name = "";
this.courses = new Vector(5);
public void addCourse(String courseName){getCourses().addElement(courseName);}
public void removeCourse(String courseName){getCourses().removeElement(courseName);}
public int getId ( ) {return id;}
public String getName ( ) {return name;}
public Vector getCourses(){ return courses;}
public void setId(int studentId) {this.id = studentId;}
public void setName(String studentName) {this.name = studentName;}
public void setCourses(Vector studentCourses){this.courses = studentCourses;}
} // end of class student
B) implementation of SessionEventAdapter class
package oracle.toplink.demos.employee.domain;
import oracle.toplink.sessions.*;
import oracle.toplink.demos.employee.relational.*;
public class MySessionEventAdapter extends SessionEventAdapter{
/* This Event is raised before the session logs in. */
public void preLogin(SessionEvent event){
System.out.println("In preLogin()");
// need empProject variable since it owns the buildStudentDescriptor() method
EmployeeProject empProject = new EmployeeProject();
event.getSession().getProject().addDescriptor(empProject.buildStudentDescriptor());
} // end of preLogin
} // end of MySessionEventAdapter
Before login to database the following two lines must be executed:
MySessionEventAdapter myAdapter = new MySessionEventAdapter();
session.getEventManager().addListener((SessionEventListener)myAdapter);
C) method that builds the ObjectRelationaDescriptor descriptor on student class
public static Descriptor buildStudentDescriptor(){
ObjectRelationalDescriptor descriptor = new ObjectRelationalDescriptor();
descriptor.setJavaClass(oracle.toplink.demos.employee.domain.Student.class);
descriptor.setTableName("TEST_STUDENT");
descriptor.setPrimaryKeyFieldName("TEST_STUDENT.STUDENT_ID");
// Mappings.
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("TEST_STUDENT.STUDENT_ID");
descriptor.addMapping(idMapping);
DirectToFieldMapping nameMapping = new DirectToFieldMapping();
nameMapping.setAttributeName("name");
nameMapping.setFieldName("TEST_STUDENT.STUDENT_NAME");
descriptor.addMapping(nameMapping);
ArrayMapping coursesMapping = new ArrayMapping(); // here we do not use ObjectArrayMapping
coursesMapping.setAttributeName("courses");
coursesMapping.setGetMethodName("getCourses");
coursesMapping.setSetMethodName("setCourses");
coursesMapping.setStructureName("COURSES_LIST_TYPE");
coursesMapping.setFieldName("TEST_STUDENT.STUDENT_COURSES");
descriptor.addMapping(coursesMapping);
return descriptor;
} // end of buildStudentDescriptor()
Defining the student descriptor this way, TopLink has all information on varray
type used. Please note that varray type already exist in database so ArrayMapping
is used instead of ObjectArrayMapping.
D) method that inserts object of type student into database
public void callObjectRelationalVArray(){
session.initializeIdentityMaps();
System.out.println("\n\n\nSTART: callObjectRelationalVArray()");
/* ************* callObjectRelationalVArray; insert student - start *******/
UnitOfWork uowInsertStudent = session.acquireUnitOfWork();
Student newStudent = new Student();
Student cloneStudent = (Student)uowInsertStudent.registerObject(newStudent);
cloneStudent.setId(6);
cloneStudent.setName("Ron Moore");
cloneStudent.addCourse("Java");
cloneStudent.addCourse("JBuilder");
cloneStudent.addCourse("HTML");
cloneStudent.addCourse("Rational Rose");
cloneStudent.addCourse("Visual Basic");
uowInsertStudent.commit();
/* ************* callObjectRelationalVArray; insert student - end *********/
System.out.println("END: callObjectRelationalVArray()");
} // end of callObjectRelationalVArray
Sample Output
By executing callObjectRelationalVarray() method JDeveloper produces the
following output:
START: callObjectRelationalVArray()
DatabaseSession(11)--Connection(12)--delete test_student where STUDENT_ID = 6
student with STUDENT_ID = 6 is deleted
DatabaseSession(11)--acquire unit of work:28
UnitOfWork(28)--begin unit of work commit
DatabaseSession(11)--Connection(12)--begin transaction
UnitOfWork(28)--Connection(12)--INSERT INTO TEST_STUDENT
(STUDENT_ID, STUDENT_NAME, STUDENT_COURSES) VALUES (?, ?, ?)
bind => [6, Ron Moore, oracle.sql.ARRAY@20]
DatabaseSession(11)--Connection(12)--commit transaction
UnitOfWork(28)--end unit of work commit
UnitOfWork(28)--release unit of work
Copyright (c) 1995,2000 Oracle Corporation. All Rights Reserved. Legal Notices and Terms of Use. -
Hi everybody..!!..
I'm writing to yours because I'm doing an application with TopLink technology and I want to update a map that I made before time with new attributes from some tables that are in the map. Is there a way to do that task without losing the named queries that I made..??..
Thanks for your help.
Greetings.The TopLink mapping tools are not intended to be round trip engineering tools so when classes are generated from tables the old classes, if any, are overwritten. The general advice for using the class generation from tables is to do it only once, at the beginning of your project to get started but from then on to managed the mappings yourself.
--Shaun -
Oc4j auto deploy cause toplink error
Hi,
We are using the OC4j 9.0.3 with toplink 4.x (latest)
We are using the SessionManager to load the mapping descriptor file
I start the appserver and everything is fine.
Then I compile the servlet. When I reload the page I get a missing descriptor
error ?
If I restart the appserver everything works fine. Is there a way withoug
restarting the app server ?
Thanks
RatnaHi Vidya,
Sounds like a classloader/classpath issue. Since I'm not sure exactly how you are deploying the servlet I'd recommend first adding a <library path> entry to the application.xml file that points to the location of the sessions.xml file. The alternative is to include this file in the WAR with the servlet. Note that the latest Oracle9iAS TopLink version is 9.0.3 and is available for download from the OTN site (http://otn.oracle.com/software/products/ias/devuse.html). Included in the download are sample TopLink applications (EJB's, Servlet/JSP's) that run on OC4J.
Hope this helps.
Thanks,
Pete Farkas -
hi,
I'm been looking up info for a while now about XMLType. I found out that Toplink Essentials not directly supports XMLType but I managed to get it from the database. When I have got the object as an oracle.xdb.XMLType then I can read it, which is good, but now (when I alter it) i have to store it again. I use this to alter my XMLType:
public static void main(String[] args) throws Exception{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("data");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
WebeMakrArtikel wma = (WebeMakrArtikel) em.find(WebeMakrArtikel.class, 1L);
String newXmlString = "<newXml></newXml>";
XMLType xml = wma.getArtikelXml();
XMLType newXml = XMLType.createXML(xml.getJavaSqlConnection(), newXmlString);
wma.setArtikelXml(newXml);
em.getTransaction().commit();
em.close();
emf.close();
}But then i get this error :
Exception in thread "main" javax.persistence.RollbackException: java.lang.NullPointerException
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:109)
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:45)
at be.roularta.schrijf.Main.main(Main.java:19)
Caused by: java.lang.NullPointerException
at oracle.sql.Datum.equals(Datum.java:65)
at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.compareObjects(AbstractDirectMapping.java:286)
at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.compareForChange(AbstractDirectMapping.java:219)
at oracle.toplink.essentials.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(DeferredChangeDetectionPolicy.java:124)
at oracle.toplink.essentials.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(DeferredChangeDetectionPolicy.java:103)
at oracle.toplink.essentials.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:81)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:476)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1108)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:82)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:842)
at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:90)
... 2 moreCan anyone help me to store this XMLType back in the database?
Why does XMLType keep the connection anyway?XMLType is supported by EclipseLink which is replacing TopLink Essentials as the JPA implementation in GlassFish V3 and will be shipped in OracleAS/TopLink 11gR1. In addition to mapping XMLType columns into XML Strings or DOMs in the domain model the support also includes expression support so that
SQLX queries can be generated.
The solution in EclipseLink involves several classes working together to handle all of the reading, writing and querying capabilities so it not easy to point at a single piece of code to solve your problem.
Doug -
Media shares auto mapping drive in Windows 8.1 Pro
What setting in Windows 8.1 is causing the automatic mapping of several shared folders named media?
I work in a university environment with staff, faculty, and students using wired and wireless networks. I have a user with a Surface Pro 3 that has started to automatically map, what seems like random addresses on the wireless network, to file shares
named media. When I setup these computers for the users I always have the media sharing turned off and I've never had cause to use it myself so I'm only a little familiar with what the settings do. I've tried to change my own settings to reproduce
the problem but I can't seem to find the correct setting so that I can reverse it. Can someone point me in the right direction?
Thanks,Hi Pete de Pistola,
If your machine keeps reconnecting to a map drive, from driver path you should be able to track down which machine is shearing folder. Also since it is a Wifi network we wonder if users could use their own device which is not configured by administrator.
As I know to prevent file sharing, group policy might be the only option.
Enable or disable File Sharing with Group Policy
https://technet.microsoft.com/en-us/library/cc754359(WS.10).aspx
Regards
Maybe you are looking for
-
A problem with hyperlinks in my Interactive PDF on smartphones...
I hope someone can help... I exported both an interactive and for print PDF from inDesign. When I view the PDFs on my pc the hyperlinks that I've made in the document work perfectly fine. When I view the PDFs on my smartphone, the hyperlinks don't
-
How to restore a database backup taken from a SQL Server 2012 instance to SQL Server 2014
I am trying to restore a database backup taken from a SQL Server 2012 instance to my new SQL Server 2014 instance. When I add the .bak through the Mgmt studio UI, it does not seem to find a backup set in the file so I cannot proceed (does not give m
-
I have been register 3 printer product HP, and HP send me 3 reply email for claim reward, but i just only can claim 1 email. The other 2 email, they claim cannot get reward because its same product. But that 3 product is all different. Helpppppppp pl
-
Portal Implementation with Unicode options on R/3 systems
Dear All, I have a very specific and unique query. We are implementing ESS, MSS, MBO for our clients, and in the process have upgraded the production servers to R/3 4.7 version ( Non - Unicode ). We're using EP 6.0 as the front for the same . My ques
-
Jdev 11g, Error when trying to run session bean
Hello, I created a session facade for my entity beans. I'm not sure what happened but when I try to run it I get the error found below. I have restarted my computer. Anyone have an idea? Thanks. Redeploying Application... <May 7, 2009 4:27:22 PM EDT>