Multiple Persistence Units AND one transaction

Hello,
I'm using JPA implementation for my EJB Project.
I have 2 persistence units and I'm using them in the same method.
I want to persist 2 object belonging each one to a different persistence unit
The 2 persistence units are related to different databases.
Everything is going fine and no exception is raised BUT only one object is persisted and the other one is not.
Have anyone had a similar problem before.
Any help will be appreciated.
Thanks in advance.
Edited by: ImaneA on Jan 18, 2011 9:29 AM

@Yordan :
First of all, thanks a lot for you answer.
At the end, I didn't use two EJB Projects :
1 - I used only one datasource( associated to one database ) in the persistence.xml
2 - I created a DBLink in SQL Server
3 - I created a synonym in the first database to get data from the second database.
And it works
But thanks for the answer, I may use you solution in my next project
@Rolf :
No, In NWA I've declared my datasources as normal datasources.
But Plz if you have docs that talks about XDataSources plz share them and thanks in advance.
Edited by: ImaneA on Jan 25, 2011 9:21 AM

Similar Messages

  • Multiple persistence units and OneToMany associations

    Hi,
    I have an EAR with two persistence units and corresponding entities. Each is contained within a separate library jar file. Some of the entities in one of the jars refer to entities in the other jar. If I refer to just a single entity (i.e., a OneToOne association), everything builds and deploys with no problems, but if I use a collection (OneToMany association), I get errors when trying to deploy the project.
    I've been playing around with this for a while and have seen different errors such as the following:
    [exec] CLI171 Command deploy failed : Deploying application in domain failed; Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    [exec] Exception Description: predeploy for PersistenceUnit [GrammarUserData] failed.
    [exec] Internal Exception: Exception [TOPLINK-7155] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException
    [exec] Exception Description: The type [interface java.util.List] for the attribute [sentencePatterns] on the entity class [class com.leadingstep.grammar.configuration.CommonElementConfiguration] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
    I also had the collection defined as a Set and it complained about that as well. I have many other OneToMany associations used between entities within the same persistence unit that use the List interface with no problems, and so that's why I'm wondering if the problem actually comes from the fact that the entities in the failed case belong to different persistence units?
    At another point, the error message I was getting was:
    [#|2009-12-22T20:05:02.427-0500|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=15;_ThreadName=Thread-32;_RequestID=67ca0eee-64d9-41dc-8093-eec811cb32b6;|Exception occured in J2EEC Phase
    com.sun.enterprise.deployment.backend.IASDeploymentException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [GrammarUserData] failed.
    Internal Exception: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: [class com.leadingstep.grammar.configuration.CommonConstructorConfiguration] uses a non-entity [class com.leadingstep.grammar.db.sentences.SentenceGroup] as target entity in the relationship attribute [private java.util.List com.leadingstep.grammar.configuration.CommonConstructorConfiguration.sentenceGroups].
    The target entity it refers to here definitely has the @Entity annotation and again, is associated with other entities within the same persistence unit with no problems.
    Am I right in thinking the problem comes from the association of entities between the different persistence units? Is there something special I have to do to make this work?
    BTW, both persistence units use the <exclude-unlisted-classes> and specifically list every entity that should be included.
    Thanks for any help!
    Renee

    One other thought on this. I'm using Glassfish with Toplink and have it create the tables using:
                   <property name="toplink.ddl-generation" value="create-tables" />
    Could it be something related to the table creation in this case that's causing the problem?
    Renee

  • Multiple persistence units not supported by OEPE 12.1.1.0.1

    Dear Friends -
    Environment
    Oracle Enterprise Pack for Eclipse 12.1.1.0.1
    JPA version : 2.0
    Platform : Eclipse link 2.3.x
    OWLS Version : 12c (12.1.1)
    JDK : jrockit1.6
    Sybase database.
    While developing JPA projects, we are getting error and warning while using Multiple persistence units in persistence.xml.
    Steps :
    1. Create 2 persistence unit in persistence.xml.
    -- Warning saying that "Multiple persistence units defined - only the first persistence unit will be recognized"
    2. Create 2 database connection in OEPE.
    3. Create JPA Entities from Table using first database connection.
    -- No issues.
    4. Create another JPA Entities from Table using second database connection.
    -- Issue is entities created in step3.(is first JPA Entity classes)
    -- Errors from first JPA Entity classes.
    ----1. Table "table_name1" cannot be resolved.
    ----2. Table "table_name1" for column "column_name1" is not valid for this entity.
    5. Second JPA Entity classes are fine.
    Thanks
    Justin.
    Sample persistence.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
         <persistence-unit name="PU1" transaction-type="JTA">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <jta-data-source>DS1</jta-data-source>
              <class>com.test.FirstEntity</class>     
         </persistence-unit>
         <persistence-unit name="PU2" transaction-type="JTA">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <jta-data-source>DS2</jta-data-source>
              <class>com.test.SecondEntity</class>
         </persistence-unit>
    </persistence>

    Also, the reason you are seeing those errors in your first project after generating entities from the second connection is because the project wide schema is being updated to the second connections generation schema. If you go into the JPA project properties you can change it back. This workflow would need to change with multiple persistence unit support.
    Neil

  • Multiple primary server and one stand by server

    Friends,
    Can we have multiple primary servers and one stand by server.
    That is to say ,\
    can we have a system where there are primary servers at different locations and one stand by server
    in another location, so that all the changes that are happenign in all teh preimary servers can be seen
    and queried in stand by server.[logical]
    Assuming the prinmary servers have the same database structure.

    can we have a system where there are primary servers at different locations For one primary server there will be one standby server.
    stand by server in another location, so that all the changes that are happenign in all teh preimary servers can be seen and queried in stand by server.[logical].You can have a standby server in a remote location and use it for reporting purpose, but you should put ur standby db in readonly mode till 10g. In 11g I think you can put ur standby database in managed recovery mode and still you can use it for reporting purpose.
    Satya.

  • Multiple persistence units with name "Model" are defined at the same scope

    Hi,
    I get this error when deploying from Jdeveloper 10.1.3.4 to OAS 10.1.3.
    The release notes for Jdev 10.1.3.1 say the following:
    "To avoid this error, update the ViewController project settings to remove the dependency on the Model project before deploying the ADF web application to Standlone OC4J."
    So I removed the dependancy but now none of my EJB's are deployed! If I go to the Enterprise Manager Console I can only see my WEB MODULE but no EJBs.
    Can anyone shed any light on this issue? Perhaps I have configured my incorrectly.
    ps. I am trying to deploy an EJB3 web app so I do not have any deployment descriptors as the documentation say that they are not needed.
    Thanks

    Also, the reason you are seeing those errors in your first project after generating entities from the second connection is because the project wide schema is being updated to the second connections generation schema. If you go into the JPA project properties you can change it back. This workflow would need to change with multiple persistence unit support.
    Neil

  • Multiple Persistence Units in persistence.xml

    Hi,
    in my session bean I want to read data from two ORACLE-database tables, which are located in two ORACLE-schemas (same ORACLE-instance). So I have defined two datasources, one for each schema. Then I defined two persistence-units in my persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
         <persistence-unit name="DACC/AEMA">
              <jta-data-source>AEMA</jta-data-source>
         </persistence-unit>
         <persistence-unit name="DACC/ALLGEMEIN">
              <jta-data-source>ALLGEMEIN</jta-data-source>
         </persistence-unit>
    </persistence>
    In NetWeaver Development Studio this result in the following error:
    "2 persistence units are found. Only exactly one persistence unti is supported."
    What's the solution here? Of course I could define two session beans. But this would result in two development components (DC) as well, because there is only 1 persistence.xml per DC (is this correct?). I don't think this is a good idea. Any other suggestions?
    Kind regards,
    Christoph

    Hi Christoph,
    From a Java EE server perspective there are no issues with multiple PUs in a persistence.xml. This is a limitation of NWDS, or WTP (Dali), to be precise. So, you could try to ignore this error and deploy on the server.
    HTH!
    \-- Vladimir

  • Multiple table commit in one transaction

    Hi ,
    I have a issue with JDBC. I have about 5 tables to update which are related. So i am updating them as one set with multiple tables.
    what i want is to commit to database once the first three tables are updated and then move on to the next 2 tables.
    Is this possible
    Regards
    Nikhil

    hi
    the xml looks like below
    <root>
    <stmt1>
    <table1 action = "update_insert">
        <table> AAA</table>
         <access>
         </access>
         <key>
         </key>
         </table1>
    <table2 action = "update_insert">
        <table> BBB</table>
         <access>
         </access>
         <key>
         </key>
         </table2>
    </stmt1>
    I have to use some thing like this because to mentain it as one transaction so that if one table update fails the whole transaction is roled back.
    If you have any idea please do let me know
    Regards
    Nikhil

  • Regarding Adding multiple SAP Scripts in one Transaction

    Hi All,
    I have a requirement where i will have to develop one custom transaction which will have multiple SAP Script Forms to it.
    The scenario is as below:
    First i will have to create a Program with Selection-Screen with 10 Radio buttons in one Block - Here Each Radio Button indicated Diffrent FORM[SAP SCRIPT].
    Down to it i will create another Block with some selection-screen fields. Like Order Type, Order No, Customer PO number, SOLD TO, BILL TO, SHIP TO etc.
    And based on Radio button selected allowed order types will vary!
    So after selecting one Form[Radio button] and enetring other selection fields once i press execute button.
    i need to display list of Orders in ALV List output with check boxes for each record in the List Output.
    Here all the radio button Forms are related to <b>Sales Order document and Delivery document</b>
    So do we need to create new ALV List Report (or) We can use submit <b>VF31</b> transaction's program <b>[sd70av3a]</b>.
    After we are displayed with orders in the output.
    Then we should provide a functionality as such if user selects mutiple Orders/Check boxes he should be able to view multiple Orders one after other, and simultaneously generate PDF Files for Each Order Selected and attach them in Mail send them to Block of users.
    Can anybody give there sujjestions.
    Without generating spool request no's is it possible to generate PDF files for SAP SCript output!
    Is it possible to Generate & attach one/multiple PDF files to mail ID and send them to list of users!
    Can anybody give inputs.
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    hi prasad,
    There is one concept called Print Work Bench(PWB) to print the multiple scripts or smartforms which r assigned to a same transaction.
    If u need the info related to PWB shoot me a test mail to [email protected]
    i will send u the same
    fot the same u can check the below link also
    http://help.sap.com/saphelp_nw04/helpdata/en/64/bf2f12ed1711d4b655006094192fe3/content.htm
    <b>Prasad i didn't get the mail from you plz check it once again</b>
    If u find it useful plz mark the points
    Regards,
    Naveen
    Message was edited by: NAVEENKUMAR GUDURI

  • Multiple ipods users and one computer

    Our household has several iPods but use one computer. I just purchased a new iPod and when I connected to the computer (Windows XP) it allowed me to identify my ipod but sunced the other ipod user's music. I'm lost - how can I or can I maintain 2 different syncs?

    When the iPods belong to different people, there are basically three ways of using multiple iPods on a computer and these involve:
    a) Sharing a single iTunes library
    b) Creating Multiple Libraries in a single user account
    c) Creating multiple user accounts.
    Note: When you are sharing an iTunes library, you don't have to set each iPod to update in the same manner, you can mix and match from the options below as each iPod has it's own update settings
    Sharing a Library and/or User Account
    If you want to share the one library, you can set either or all of the iPods so that they only get updated with only certain playlists (you can update from more than one if you wish): Loading songs onto iPod automatically - Windows
    Choosing the update option "Sync Music - Selected playlists" allows you to create a playlist specifically for the iPod and drag the tracks you want into it. If you tire of the list and want to change it, you just add or remove the songs you don't want. The ones you take out out remain in the library to be used some other time if you choose. You can read more about playlists at these links:
    iTunes: Creating playlists of your favorite songs
    How to create a Smart Playlist with iTunes
    Or you can choose to update any or all of the iPods manually and just drag whatever content you want to them: Managing content manually on iPod
    Loading the iPod shuffle differs slightly but it can still be used with the others, for details have a look at this page: Loading songs onto iPod shuffle - Windows
    Multiple Libraries
    It's also possible to have multiple libraries in a single account. To create or access a second (or more) library, hold down the Shift key (or the Option key on a Mac) when launching iTunes 7. In the resulting dialogue you will get the option to create a new library or navigate to the other Library.
    Note: You can only have one Library open at a time and iTunes will default to the last library opened if you don't use the keyboard command to choose one. This can prove tricky when using multiple iPods, if you don't use the keyboard command you can risk syncing to the wrong library: Using multiple iTunes libraries -Windows
    Separate User Accounts
    Another option is to create a separate User account for each person on your PC or Mac. Different accounts by definition would give you completely separate libraries. Each account has it's own iTunes folder, Library and iTunes Music folder and you load it with CDs etc just as you did with your original one. The iPod can be set to update however the owner chooses, sync all, manual or sync specific playlists
    I don't use Windows so I can't give you a step by step on that one, however I can point you to another web page which should help you out. You can read about Windows user accounts here: Using Windows XP User Accounts

  • Multiple Hard Drives and One Library...is it possible?

    this is a repost, my last post got jacked.
    Hi, I've been doing some looking around here already for a good solution, but have yet to find it, including some of the existing threads dealing with similar issues.
    So here is my scenario: Laptop with a hard drive that is almost full, need to move two thirds to an external drive, however I need to maintain the integrity of the whole library (current playlists, playcounts etc), none of this option key launching stuff, and separate libraries. My concerns, with doing some initial testing, is that itunes still asks for the location of the music files when they have been moved to another drive, I don't want to and shouldn't have to re-locate each file individually (30+gbs). It seems like I either have to do one thing or the other can't do both. Move everything and re-direct it to the new location and re-import to the local drive, or go the option click route which I don't really want to (and I would lose some of my library info in the process). Is what I'm asking to do even possible with the constraints of splitting an existing library of music, with one library file & multiple drives?
    Thanks for any info or help.
    iMac 17 1ghz G4 1.25gb ram / iBook 1.25ghz G4 768mb ram   Mac OS X (10.4.6)  

    You can check/change the permissions on the library folder in the Finder-File>GetInfo window. Set Group and Others to Read&Write.

  • How to Configure iCloud with multiple iCloud accounts and one apple id

    I need some help from the icloud experts. I almost have my arms around this, but not completely.
    What I want to end up with is the following:
    One account that both my wife and I use for shared contacts, calendars, photostream and find my device.
    Separate account for my email among several devices.
    Separate account for my wife for her email among several devices.
    Now what I curently have is an apple id (*.mac.com), which is the main account used for purchases, etc. It has my mail, backups, and 25GB of space as a result from MobileMe.
    I created a separate icloud account for my wife, using her Apple ID, so that her mail stayed separate from mine. However, now we have separate photo streams, contacts, etc, which is getting confusing and cumbersome.
    I would like to keep my apple id as the main account since it already has the 25GB of space. So tell me if the following make sense.
    I setup the master account using my apple id (the one with 25GB of space) for both of us, and enable the contacts and calendar syncing for all of our devices.
    I turn the mail and Safari bookmarks syncing on for my devices; but turn it off  for my wife's devices.
    Then I use my wife's account on her devices to sync her mail, bookmarks, etc.
    Would this work or is there another combination to use? Ideally a family oriented apple id would be good for the master account, but it wouldn't have the 25GB of space unless I purchased it. I'm trying to get around that if possible. I have tried to find something like this on the discussion boards but haven't had luck yet.
    Thanks in advance for any help.

    Set up your mac.com account again on devices.  Turn off Mail and other data syncing with this account on your wife's devices for data that you want to keep separate.  Then set up a second ("secondary") iCloud account on your wife's devices to sync Mail.
    If you already set up a separate iCloud account on your wife's devices, on her devices go to Settings>iCloud, tap Delete Account, then sign back in your your mac.com ID.  Turn on the data you want to share with this account across all devices; don't turn Mail on.  Then go to Settings>Mail,Contacts,Calendars>Add Account>iCloud and enter her separate iCloud credentials and turn Mail to On.
    The only downside to this approach is that her email will be fetch, not push email.  Push email is only supported in the main ("primary") account, not a secondary account.
    The limitations to be aware of with secondary accounts are that only the primary account can be used for Photo Stream, Bookmarks, Documents, iCloud Backup and Find My Device.  Also, push mail only works for the primary account; secondary account mail is fetch.

  • Chart for representing multiple inputs (conditions) and one output

    Hello everyone,
    I am using Microsoft Excel 2010.
    I have a list of sells. Each sell amount can be only one from the following range $25, $30, $50, $40, $75, $85, $100 and number of clients can be any number between 0 and 500 in each month. We assume each client will buy the services at least once a year or
    at most once a month. A sales representative will make 10% profit out of these sells.
    What type of chart representation can best show the minimum and maximum profits per month during a year for a sales rep.?
    Any help is appreciated in advance.
    Thanks

    Hello Ring Gee.
    Thanks for reply,
    Suppose you are working for a company, consider the followings at the end of the first month. They will pay you 10% commission if you sell the telephone services to 100 people. You will continue to receive this amount of commission for 12 months. If you
    sell the telephone services to 300 people your commission rate will be 14% and they will pay you this commission for 20 months. This means in the first case you will receive $3000 to $12000  (varies by sell's amount) and if you sell the services to 600
    clients you will receive between $96000 and $384000 (varies by sell's amount). 
    This way, life time and rate of your commission will increase if you increase the number of sells. 
    Is it clear enough? 
    I want to visualize this scenario using the chart that covers all conditions. There was no option to upload the actual excel file, so I took a picture of it. Look at the image bellow please: 

  • Multiple iPhone 4s and one iTunes

    How do I synch different music on my iphone 4 and my wifes iphone 4 using the same itunes account without synching apps?

    I tried that approach.  However, every time I tried to synch her phone (after selecting and confirming not to synch the apps), it synched every app of mine on to her phone.  So I had to delete all my apps from her phone. I just want to synch music. Any other suggestions?  Thanks!

  • Extended Persistence Context And user transaction

    Hello
    I use Extended persistence context with stateful session bean in my app, but when i persist object it does not store in database,i dont know whats wrong:
    @Stateful
    @TransactionManagement(TransactionManagementType.BEAN)
    public class ProfessionAction implements ProfessionLocal {
         @PersistenceContext(type = PersistenceContextType.EXTENDED)
         private EntityManager em;
         @Transient
         private Logger log;
         @Resource
         private UserTransaction ut;
         public Profession add( Profession p) {
              try {
                   log.info("Adding Profession...");
                   ut.begin();
                   em.persist(p);
                   ut.commit();
                   log.info("Profession Added...");
              } catch (Exception ex) {
                   log.error(ex.getMessage(), ex);
              return p;
         }

    What if you change the code to this:
    @Stateful
    @TransactionManagement(TransactionManagementType.BEAN)
    public class ProfessionAction implements ProfessionLocal {
    @PersistenceContext(type = PersistenceContextType.EXTENDED)
    private EntityManager em;
    @Transient
    private Logger log;
    public Profession add( Profession p) {
    try {
    log.info("Adding Profession...");
    em.getTransaction().begin();
    em.persist(p);
    em.getTransaction().commit();
    log.info("Profession Added...");
    } catch (Exception ex) {
    log.error(ex.getMessage(), ex);
    return p;
    }?

  • Multiple different devices and one email account

    Hi guys,
    Is it possible to receive emails immediately to the ipad or iphone? I know that the settings have to be on push messages which it is but the actual settings for the email account is for fetch only. Does that affect the time that the email gets received on either device? The email account is not an icloud email or the others that are listed as possible options, does this also affect download time?
    I know there is an option to link many devices to one account with out affecting any of the devices but I cannot remember how. Assistance in this regard would be much appreciated!
    Thanks

    An email account must support push access, which is not supported with a POP account.
    Push access means as soon as an email is received at the incoming mail server, the incoming mail server pushes the email out without having to automatically or manually check the account for new email, which is Fetch. With Fetch, you can set the Fetch setting to automatically check the account for new email at a designated internal - every 15 minutes or every 30 minutes along with being able to manually check the account for new email in between the automatic check time interval.

Maybe you are looking for