Many to Many relation problem

Hi,
JDeveloper 11.1.1.6
3 tables, let's name them A, B and RelAB
By default, there is a [1 to *] from A to RelAB and a [1 to *] from B to RelAB.
Since I wanted to use a master-detail view on my web page, I didn't have the choice to modify these Associations and Links to a [* to *] from A to B, and as well from B to A.
Now you test the whole thing by running the AppModule. Everything works like a charm.
The problem is if I go into my A view object and then I change the SQL Mode from Normal to Expert inside the Query tab, the minute I run my AppModule, one of my many to many relationship breaks. Notice that I did not change anything else, just switch from Normal to Expert. Let's say that the A to B relation is working but not the B to A.
If I put it back to Normal, it works again. You might want to ask, why bother with Expert Mode? It is just that I want to modify this query, I was just trying to identify the source of the problem.
Anybody experience a similar problem with many-to-many relationships?

I assume your question is on JAXB, correct?
I think you need to make on side of the relationship transient, or remove it.
James : http://www.eclipselink.org

Similar Messages

  • Many to Many Relations Problem

    I have following two classes with many-to-many case:
    public class Protocol {
    private long protocolId;
    private final Collection keyPersons = new ArrayList();
    public void addKeyPerson(Person person) {
    person.addKeyProtocol(this);
    public void removeKeyPerson(Person person) {
    person.removeKeyProtocol(this);
    public class Person {
    private long personId;
    private final Collection keyProtocols = new ArrayList();
    public void addKeyProtocol(Protocol protocol) {
    protocol.getKeyPersonsCollection().add(this);
    keyProtocols.add(protocol);
    public void removeKeyProtocol(Protocol protocol) {
    protocol.getKeyPersonsCollection().remove(this);
    keyProtocols.remove(protocol);
    The meta data is:
    <?xml version="1.0"?>
    <jdo>
    <package name="peacetech.nih.nhlbi.iasp.dao">
    <class name="Protocol" identity-type="application"
    objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.ProtocolOid">
    <extension vendor-name="tt" key="table" value="protocol"/>
    <extension vendor-name="tt" key="pk-column" value="int_protocol"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="protocolId" primary-key="true">
    <extension vendor-name="tt" key="data-column" value="int_protocol"/>
    </field>
    <field name="keyPersons">
    <collection element-type="Person"/>
    <extension vendor-name="tt" key="inverse" value="keyProtocols"/>
    <extension vendor-name="tt" key="table" value="KeyPersonnel"/>
    <extension vendor-name="tt" key="personId-data-column" value="PID"/>
    <extension vendor-name="tt" key="protocolId-ref-column"
    value="int_protocol"/>
    </field>
    </class>
    <class name="Person" identity-type="application"
    objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.PersonOid">
    <extension vendor-name="tt" key="table" value="Personnel"/>
    <extension vendor-name="tt" key="pk-column" value="PID"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="personId" primary-key="true">
    <extension vendor-name="tt" key="data-column" value="PID"/>
    </field>-
    <field name="keyProtocols">
    <collection element-type="Protocol"/>
    <extension vendor-name="tt" key="inverse" value="keyPersons"/>
    <extension vendor-name="tt" key="table" value="KeyPersonnel"/>
    <extension vendor-name="tt" key="protocolId-data-column"
    value="int_protocol"/>
    <extension vendor-name="tt" key="personId-ref-column" value="PID"/>
    </field>
    </class>
    The assignment works fine beetwen New Persistent Protocol and Persons, but
    when ever I try to add new assignment between existing protocol and person:
    void updateProtocol(PersistenceManager pm){
    Extent e = pm.getExtent (Person.class, true);
    Query query = pm.newQuery (Person.class, e, "fname == \"Alex\"");
    Collection collection = (Collection) query.execute();
    Iterator i = collection.iterator ();
    Person alex = (Person)i.next();
    System.out.println("Person to assign" + alex);
    e = pm.getExtent (Protocol.class, true);
    query = pm.newQuery (Protocol.class, e, "projectTitle == \"This is
    JDO test N1\"");
    collection = (Collection) query.execute();
    i = collection.iterator ();
    Protocol firstProtocol = (Protocol)i.next();
    try {
    pm.currentTransaction().begin();
    e = pm.getExtent (Person.class, true);
    query = pm.newQuery (Person.class, e, "fname == \"Brian\"");
    collection = (Collection) query.execute();
    i = collection.iterator ();
    while (i.hasNext ())
    firstProtocol.addKeyPerson((Person)(i.next()));/*Exception
    here!*/
    pm.currentTransaction().commit();
    } catch (Exception ex) {
    pm.currentTransaction().rollback();
    ex.printStackTrace(System.out);
    I have following exception:
    javax.jdo.JDOUserException: The given element "
    =======Person=======
    First Name: Brian
    Last Name: Agricola
    Phone: null
    Email: null
    ====================" does not meet the requirements for the container.
    at
    com.solarmetric.kodo.util.SecondClassObjects.checkValue(SecondClassObjects.j
    ava:224)
    at com.solarmetric.kodo.util.ProxyLinkedList.add(ProxyLinkedList.java:71)
    at peacetech.nih.nhlbi.iasp.dao.Person.addKeyProtocol(Person.java:176)
    at peacetech.nih.nhlbi.iasp.dao.Protocol.addKeyPerson(Protocol.java:147)
    at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:142)
    at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:110)
    at peacetech.nih.nhlbi.iasp.IASPTest.runTest(IASPTest.java:28)
    at peacetech.nih.nhlbi.iasp.IASPTest.main(IASPTest.java:22)
    I have the same problem also for one to many.
    Can you help me with it?
    Thanks,
    Kirill.

    I have following two classes with many-to-many case:
    public class Protocol {
    private long protocolId;
    private final Collection keyPersons = new ArrayList();
    public void addKeyPerson(Person person) {
    person.addKeyProtocol(this);
    public void removeKeyPerson(Person person) {
    person.removeKeyProtocol(this);
    public class Person {
    private long personId;
    private final Collection keyProtocols = new ArrayList();
    public void addKeyProtocol(Protocol protocol) {
    protocol.getKeyPersonsCollection().add(this);
    keyProtocols.add(protocol);
    public void removeKeyProtocol(Protocol protocol) {
    protocol.getKeyPersonsCollection().remove(this);
    keyProtocols.remove(protocol);
    The meta data is:
    <?xml version="1.0"?>
    <jdo>
    <package name="peacetech.nih.nhlbi.iasp.dao">
    <class name="Protocol" identity-type="application"
    objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.ProtocolOid">
    <extension vendor-name="tt" key="table" value="protocol"/>
    <extension vendor-name="tt" key="pk-column" value="int_protocol"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="protocolId" primary-key="true">
    <extension vendor-name="tt" key="data-column" value="int_protocol"/>
    </field>
    <field name="keyPersons">
    <collection element-type="Person"/>
    <extension vendor-name="tt" key="inverse" value="keyProtocols"/>
    <extension vendor-name="tt" key="table" value="KeyPersonnel"/>
    <extension vendor-name="tt" key="personId-data-column" value="PID"/>
    <extension vendor-name="tt" key="protocolId-ref-column"
    value="int_protocol"/>
    </field>
    </class>
    <class name="Person" identity-type="application"
    objectid-class="peacetech.nih.nhlbi.iasp.dao.oid.PersonOid">
    <extension vendor-name="tt" key="table" value="Personnel"/>
    <extension vendor-name="tt" key="pk-column" value="PID"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="personId" primary-key="true">
    <extension vendor-name="tt" key="data-column" value="PID"/>
    </field>-
    <field name="keyProtocols">
    <collection element-type="Protocol"/>
    <extension vendor-name="tt" key="inverse" value="keyPersons"/>
    <extension vendor-name="tt" key="table" value="KeyPersonnel"/>
    <extension vendor-name="tt" key="protocolId-data-column"
    value="int_protocol"/>
    <extension vendor-name="tt" key="personId-ref-column" value="PID"/>
    </field>
    </class>
    The assignment works fine beetwen New Persistent Protocol and Persons, but
    when ever I try to add new assignment between existing protocol and person:
    void updateProtocol(PersistenceManager pm){
    Extent e = pm.getExtent (Person.class, true);
    Query query = pm.newQuery (Person.class, e, "fname == \"Alex\"");
    Collection collection = (Collection) query.execute();
    Iterator i = collection.iterator ();
    Person alex = (Person)i.next();
    System.out.println("Person to assign" + alex);
    e = pm.getExtent (Protocol.class, true);
    query = pm.newQuery (Protocol.class, e, "projectTitle == \"This is
    JDO test N1\"");
    collection = (Collection) query.execute();
    i = collection.iterator ();
    Protocol firstProtocol = (Protocol)i.next();
    try {
    pm.currentTransaction().begin();
    e = pm.getExtent (Person.class, true);
    query = pm.newQuery (Person.class, e, "fname == \"Brian\"");
    collection = (Collection) query.execute();
    i = collection.iterator ();
    while (i.hasNext ())
    firstProtocol.addKeyPerson((Person)(i.next()));/*Exception
    here!*/
    pm.currentTransaction().commit();
    } catch (Exception ex) {
    pm.currentTransaction().rollback();
    ex.printStackTrace(System.out);
    I have following exception:
    javax.jdo.JDOUserException: The given element "
    =======Person=======
    First Name: Brian
    Last Name: Agricola
    Phone: null
    Email: null
    ====================" does not meet the requirements for the container.
    at
    com.solarmetric.kodo.util.SecondClassObjects.checkValue(SecondClassObjects.j
    ava:224)
    at com.solarmetric.kodo.util.ProxyLinkedList.add(ProxyLinkedList.java:71)
    at peacetech.nih.nhlbi.iasp.dao.Person.addKeyProtocol(Person.java:176)
    at peacetech.nih.nhlbi.iasp.dao.Protocol.addKeyPerson(Protocol.java:147)
    at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:142)
    at peacetech.nih.nhlbi.iasp.IASPTest.updateProtocol(IASPTest.java:110)
    at peacetech.nih.nhlbi.iasp.IASPTest.runTest(IASPTest.java:28)
    at peacetech.nih.nhlbi.iasp.IASPTest.main(IASPTest.java:22)
    I have the same problem also for one to many.
    Can you help me with it?
    Thanks,
    Kirill.

  • A many-to-many relational problem (SQL and CFM)

    My question:
    How to get CFM to return a many-to-many relationship in one
    row using cfloop
    My table structure:
    Table A - Books
    BookID | BookName
    1 | Book One
    Table B -
    RelatingTable
    BookID | AuthorID
    1 | 60
    1 | 61
    Table C - Authors
    AuthorID | AuthorName
    60 | Bob
    61 | Joe
    My query:
    SELECT * FROM Books, RelatingTable, Authors AS a
    INNER JOIN Books AS b ON b.BookID = r.BookID
    INNER JOIN RelatedTable AS r ON r.AuthorID = a.AuthorID
    Output I am getting:
    b.BookID | b.BookName | r.BookID | r.AuthorID | a.AuthorID |
    a.AuthorName
    ---------|------------|----------|------------|------------|-------------
    1 | Book One | 1 | 60 | 60 | Bob
    1 | Book One | 1 | 61 | 61 | Joe
    I am using a UDF that turns my relationship into a comma list
    (authorlist), but the duplicates still return in CFM because the
    JOIN relationship
    The code I am using in CFM:
    <cfloop query="rsBooksQuery">
    #b.BookName#, written by #authorlist#
    </cfloop>
    How Coldfusion is displaying my output:
    Book One, written by Bob, Joe
    Book One, written by Bob, Joe
    How I want my output displayed:
    Book One, written by Bob, Joe
    I need this to work in cfloop and not cfoutput! I know that
    you can use group in CF output, but for the conditions I am using
    this query, it must be in a loop
    the reason why i keep the JOINs even though i have a UDF to
    create a comma list is that some of my CFM pages use variables
    passed to the qry to limit which books are displayed, for example
    &author=60 (which would display a list of Bob's books that
    include the comma list)
    If you can suggest anything to help me I will be very
    thankful

    I need this to work in cfloop and not cfoutput! I know that
    you can use
    group in CF output, but for the conditions I am using this
    query, it
    must be in a loop
    If you can suggest anything to help me I will be very
    thankful
    If you can not use <cfoutput...> with its group
    feature, you need to
    recreate the functionality with <cfloop...>. You can
    create nested
    <cfloop...> tags that keep track of the changing group
    value. It takes
    more code, but that's what happens when one sets outside the
    bounds of
    the built in functionality.

  • Problem in mapping a many to many relation to a list

    Hi,
    I have a problem with mapping a many to many relation to a list.
    I have a Many to Many relation in my database between tables baskets and products. This relation is implemented with a join table basket_products, which has two fields which correspond to the foreign keys to tables baskets and products. The join table need to have another one column "order", which defines the order of the products for the specific basket.
    In my mapping I have:
    @Entity
    @Table(name = "baskets", uniqueConstraints = {})
    public class Components implements java.io.Serializable {
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
         @JoinTable( name="baskets_products",
                             joinColumns=@JoinColumn(name="b_id", referencedColumnName="pr_id"),
                             inverseJoinColumns=@JoinColumn(name="pr_id", referencedColumnName="pr_id"))
            //This of course doesn't work!!
           //@OrderBy(value="order")
         public List<Products> getProductses() {
              return this.productses;
         public void setProductses(
                   List<Products> productses) {
              this.productses = productses;
    @Entity
    @Table(name = "products", uniqueConstraints = { })
    public class Products implements java.io.Serializable {
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "productses")
         public Set<Baskets> getBasketses() {
              return this.basketses;
         public void setBasketses(Set<Basket> basketses) {
              this.basketses = basketses;
         }In the EJB spec I read that :
    "The property or field name must correspond to that of a persistent property or field of the associated
    class."
    What to do if I want to use a field from the join table to do the ordering of the list??
    My problem is that the field "order", is not defined to the EJB container as a persistent field, so it cannot be used. But for my needs it is necessary that this field is included in the join table.
    I thought that I could use the secondary table annotation to map the join table to the Baskets class, as well, so that I can define the order field, but this solution seems to me as a really wrong one.
    Can anyone help me??
    Thanks,
    Elenh.

    Hi Martin-
    Can you please help me. Here are the details:
    We have created an AQ in Oracle DB which will have the following message Structure:
    CREATE OR REPLACE TYPE enqueue_payload AS OBJECT
    ( field1 VARCHAR2(100),
    field2 VARCHAR2(100),
    field3 DATE,
    field4 VARCHAR2(100),
    field5 NUMBER,
    payload CLOB,
    In the Payload field we are enqueing an XML message.
    We have to use a OSB proxy service to dequeue the message from the AQ, transform it to another format and send to a SOA Composite.
    We created a AQ Adapter in Jdeveloper 11g and imported the WSDL, XSD and .jca jca binding file into the OSB project. And configured the OSB proxy service using the WSDL imported.
    However in OSB proxy service message flow when I try to create an XQUERY transformation, I see that the Payload field does not expose the structure of the XML message that is being enqueued. I even changed the message structure definition to have the payload field as XMLType. But it didn't help.
    On analyzing the XSD created by AQ Adapter, I see that the payload is being defined as "string" in the XSD.
    Inputs Needed
    =========
    1. How can we parse the payload field defined as CLOB/XMLType in OSB so that I can see the structure of the XML message it holds ?
    2. Is there any in-built function in OSB to convert it to XML ?
    3. Any other inputs in order to transform the XML message coming in the payload field as CLOB/XMLType
    Please provide your inputs and I hope that I have clearly explained my use case.
    Thanks in advance for your time and help!!
    Regards,
    Dibya

  • TopLink11 Tutorial problems with one-to-many relation

    Hi,
    I installed TopLink 11 and the related tutorial to work in a simple Eclipse project.
    Everthing works fine except for the storing of the one-to-many relation in the database.
    The tutorial works with employee, address and phone tables/classes. Plain Objects can be stored and one-to-one relations too. However when trying to store a one-to-many relation not the key of the related object (which is at that tome well known) but the object is tried to be entered
    in the Logfile I find:
    [TopLink Fine]: 2008.01.10 10:27:28.748--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--INSERT INTO EMPLOYEE (EMP_ID, L_NAME, F_NAME, ADDR_ID, VERSION) VALUES (?, ?, ?, ?, ?)
         bind => [1501, Pascal, Blaise, 2252, 1]
    [TopLink Finer]: 2008.01.10 10:27:28.748--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--commit transaction
    [TopLink Finer]: 2008.01.10 10:27:28.748--UnitOfWork(14858725)--Thread(Thread[main,5,main])--end unit of work commit
    [TopLink Finer]: 2008.01.10 10:27:28.748--UnitOfWork(14858725)--Thread(Thread[main,5,main])--release unit of work
    [TopLink Finer]: 2008.01.10 10:27:28.748--UnitOfWork(14858725)--Thread(Thread[main,5,main])--release unit of work
    [TopLink Finest]: 2008.01.10 10:27:28.748--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Register the object Employee: Blaise Pascal
    [TopLink Finest]: 2008.01.10 10:27:28.748--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Execute query DoesExistQuery()
    [TopLink Finer]: 2008.01.10 10:28:58.370--UnitOfWork(18511661)--Thread(Thread[main,5,main])--begin unit of work commit
    [TopLink Finer]: 2008.01.10 10:28:58.370--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--begin transaction
    [TopLink Finest]: 2008.01.10 10:28:58.370--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Execute query UpdateObjectQuery(Employee: Blaise Pascal)
    [TopLink Finest]: 2008.01.10 10:28:58.386--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Execute query InsertObjectQuery(PhoneNumber[desk]: (603) 123-4567)
    [TopLink Fine]: 2008.01.10 10:28:58.386--DatabaseSessionImpl(12916846)--Connection(9550256)--Thread(Thread[main,5,main])--INSERT INTO PHONE (P_NUMBER, EMP_ID, AREA_CODE, TYPE) VALUES (?, ?, ?, ?)
         bind => [1234567, {Employee: Blaise Pascal}, 603, desk]
    [TopLink Warning]: 2008.01.10 10:28:58.511--UnitOfWork(18511661)--Thread(Thread[main,5,main])--Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g Technology Preview 3 (11.1.1.0.0) (Build 071214)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Ungültiger Spaltentyp Error Code: 17004
    the highlighted section should be 1501 (the key of the employee record)
    Any ideas how to fix this?
    Thanks Erika

    Erika,
    You need to specify the other side of the relationship (on the PhoneNumber side), which is done by putting a @ManyToOne annotation on the "employee" attribute in PhoneNumber. That will cause TopLink to know that it is a relationship and not a basic mapping.
    -Mike

  • One to many relation doesn't work

    I tried without success to get a simple one to many relationship to work.
    The select works fine but
    I still have problems with insert.
    I have two tables on a existing schema:
    1     ANAG (ID_ANAG primary key,...)
    2     INDI (ID_INDI primary key, ID_ENTITA,...), where INDI.ID_ENTITA points
    to ANAG.ID_ANAG
    the two classes are:
    1     public class Anagrafica
         private int idAnag; //ID_ANAG
         private String ragSoc;
         private String ragSocFonet;
         private String codFisc;
         private String sesso;
         private Integer codTit;
         private Date dtNasc;
         private HashSet indis;
    2     public class Indirizzo
         private int idIndi; //ID_INDI
         private long idEntita; //ID_ENTITA
         private long tpEntita;
         private String indirizzo;
         private String localita;
         private String prov;
         private String cap;
         private Anagrafica anagrafica;
    the two metadata:
    1      anagrafica.jdo:
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.44.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Anagrafica"
    identity-type="application"
    objectid-class="domain.AnagraficaPK">
    <extension key="table" value="ANAG" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <field name="idAnag" primary-key="true">
    <extension key="data-column" value="ID_ANAG"
    vendor-name="kodo"/>
    </field>
    <field name="ragSoc">
    <extension key="data-column" value="RAG_SOC"
    vendor-name="kodo"/>
    </field>
    <field name="ragSocFonet">
    <extension key="data-column" value="RAG_SOC_FONET"
    vendor-name="kodo"/>
    </field>
    <field name="codFisc">
    <extension key="data-column" value="COD_FISC"
    vendor-name="kodo"/>
    </field>
    <field name="sesso">
    <extension key="data-column" value="SESSO"
    vendor-name="kodo"/>
    </field>
    <field name="codTit">
    <extension key="data-column" value="COD_TIT"
    vendor-name="kodo"/>
    </field>
    <field name="dtNasc">
    <extension key="data-column" value="DT_NASC"
    vendor-name="kodo"/>
    </field>
    <field name="indis">
    <collection element-type="domain.Indirizzo"/>
    <extension vendor-name="kodo" key="table" value="INDI"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
    <extension vendor-name="kodo" key="idEntita-ref-column"
    value="ID_ANAG"/>
         </field>
    </class>
    </package>
    </jdo>
    2 Indirizzo.jdo
    <?xml version="1.0"?>
    <!-- This JDO Metadata file was auto-generated on 08/10/02 17.21.
    See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
    <jdo>
    <package name="domain">
    <class name="Indirizzo"
    identity-type="application" objectid-class="domain.IndiPK">
    <extension key="table" value="INDI" vendor-name="kodo"/>
    <extension key="class-column" value="none" vendor-name="kodo"/>
    <extension key="lock-column" value="none" vendor-name="kodo"/>
    <!--extension vendor-name="kodo" key="idEntita-data-column"
    value="ID_ENTITA"/-->
    <field name="idIndi" primary-key="true">
    <extension key="data-column" value="ID_INDI"
    vendor-name="kodo"/>
    </field>
    <field name="idEntita">
    <extension key="data-column" value="ID_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="tpEntita">
    <extension key="data-column" value="TP_ENTITA"
    vendor-name="kodo"/>
    </field>
    <field name="indirizzo">
    <extension key="data-column" value="INDIRIZZO"
    vendor-name="kodo"/>
    </field>
    <field name="localita">
    <extension key="data-column" value="LOCALITA"
    vendor-name="kodo"/>
    </field>
    <field name="prov">
    <extension key="data-column" value="PROV"
    vendor-name="kodo"/>
    </field>
    <field name="cap">
    <extension key="data-column" value="CAP"
    vendor-name="kodo"/>
    </field>
    <field name="anagrafica">
    <extension vendor-name="kodo" key="idAnag-data-column"
    value="ID_ENTITA"/>
    </field>
    </class>
    </package>
    </jdo>
    The problem is:
    I create a new Anagrafica object and then I try to save it in the
    database. These are the SQL
    statements that are generated:
    INSERT INTO ANAG(DT_NASC, COD_FISC, RAG_SOC_FONET, SESSO, ID_ANAG,
    RAG_SOC, COD_TIT)
    VALUES (NULL, NULL, 'NATALE', NULL, 971963921, 'Natale', NULL)
    INSERT INTO INDI(TP_ENTITA, PROV, LOCALITA, ID_ENTITA, ID_INDI, INDIRIZZO,
    CAP)
    VALUES (0, NULL, NULL, 0, 971963921, 'via 25 dicembre', NULL)
    Why is the value of ID_ANAG (971963921) assigned to ID_INDI and not to
    ID_ENTITA?
    Regards
    Mirko

    Abe White wrote:
    <field name="indis">
    <collection element-type="domain.Indirizzo"/>
    <extension vendor-name="kodo" key="table" value="INDI"/>
    <extension vendor-name="kodo" key="inverse"
    value="anagrafica"/>
    <extension vendor-name="kodo" key="idEntita-ref-column"
    value="ID_ANAG"/>
         </field>
    Get rid of all extensions except the inverse:
    <field name="indis">
    <collection element-type="domain.Indirizzo"/>
    <extension vendor-name="kodo" key="inverse" value="anagrafica"/>
    </field>
    As in the examples in our documentation, all 1-many relations should only
    list their inverse 1-1 relation.
    Also, make sure your object model is consistent; i.e. make sure you'resetting
    both sides of the relation:
    indi.setAnagrafica (anag);
    anag.getIndis ().add (indi);
    Let us know if you continue to have problems.Hi Abe,
    I got rid of the unnecessary extensions and I set both sides of the
    relation as you suggest but I still have the same problem:
    INSERT INTO ANAG(ID_ANAG) VALUES (2088176453)
    INSERT INTO INDI(ID_INDI, ID_ENTITA) VALUES (2088176453, NULL)
    while I expect
    INSERT INTO ANAG(ID_ANAG) VALUES (2088176453)
    INSERT INTO INDI(ID_INDI, ID_ENTITA) VALUES (<some ID>, 2088176453)
    any ideas?
    regards

  • FatalUserException / One-Many relation relinking

    Hello all,
    I have a problem with one-many relations and relinking... Let's have a
    relation one-many between class Task and itself (classic parent-children
    problem).
    Initial Context
    - T1 has 2 child (T2, T3)
    What i need to do : move T3 as child of T2 to have :
    - T1 has 1 child (T2)
    - T2 has one child (T3)
    How i do it (using a global transaction) :
    transaction.begin();
    // unlinking T3 from T1
    T1.parent = null;
    T3.getChildren().remove(T1)
    // relink T3 to T2
    T1.parent = T2;
    T2.getChildren().add(T1);
    transaction.commit();
    I get this exception :
    Attempt to set column "TASK.parent" to two different values: (class
    java.lang.String)"T2", (null)"null" This can occur when you fail to set
    both sides of a two-sided relation between objects, or when you map
    different fields to the same column, but you do not keep the values of
    these fields in synch.
    When i test without a global transaction like this :
    transaction.begin();
    // unlinking T3 from T1
    T1.parent = null;
    T3.getChildren().remove(T1)
    transaction.commit();
    transaction.begin();
    // relink T3 to T2
    T1.parent = T2;
    T2.getChildren().add(T1);
    transaction.commit();
    With atomic transaction, everything is always fine. My problem is that I
    need to use global transaction because I need a global rollback and only
    one commit per big process, so I can't use atomic transactions (atomic
    commits takes too much time comparing to a global one) as this :
    Here we're in a particular case where I need to relink a task from a
    parent to its brother. In cases where new parent and old one have no
    close links, global transactions work fine, so this exception is not
    always thrown, which seems pretty weird to me.
    Working case using global transaction :
    =====================
    a) initial context
    T1 have 1 child(T2)
    T3 have 0 child
    b) actions
    moving T2 to T3 with global transaction
    c) result
    T1 have 0 child
    T3 have 1 child(T2)
    =====================
    This is very problematic and strange to me, so any help is welcomed...
    Thomas

    Looks like you use parent/children relationsheep wrongly. Try this instead:
    transaction.begin();
    // unlinking T3 from T1
    //T1.parent = null;
    T1.getChildren().remove(T3)
    // relink T3 to T2
    //T1.parent = T2;
    T3.parent = T2;
    T2.getChildren().add(T3);
    transaction.commit();
    "Thomas cornet" <[email protected]> wrote in message
    news:[email protected]...
    Hello all,
    I have a problem with one-many relations and relinking... Let's have a
    relation one-many between class Task and itself (classic parent-children
    problem).
    Initial Context
    - T1 has 2 child (T2, T3)
    What i need to do : move T3 as child of T2 to have :
    - T1 has 1 child (T2)
    - T2 has one child (T3)
    How i do it (using a global transaction) :
    transaction.begin();
    // unlinking T3 from T1
    T1.parent = null;
    T3.getChildren().remove(T1)
    // relink T3 to T2
    T1.parent = T2;
    T2.getChildren().add(T1);
    transaction.commit();
    I get this exception :
    Attempt to set column "TASK.parent" to two different values: (class
    java.lang.String)"T2", (null)"null" This can occur when you fail to set
    both sides of a two-sided relation between objects, or when you map
    different fields to the same column, but you do not keep the values of
    these fields in synch.
    When i test without a global transaction like this :
    transaction.begin();
    // unlinking T3 from T1
    T1.parent = null;
    T3.getChildren().remove(T1)
    transaction.commit();
    transaction.begin();
    // relink T3 to T2
    T1.parent = T2;
    T2.getChildren().add(T1);
    transaction.commit();
    With atomic transaction, everything is always fine. My problem is that I
    need to use global transaction because I need a global rollback and only
    one commit per big process, so I can't use atomic transactions (atomic
    commits takes too much time comparing to a global one) as this :
    Here we're in a particular case where I need to relink a task from a
    parent to its brother. In cases where new parent and old one have no
    close links, global transactions work fine, so this exception is not
    always thrown, which seems pretty weird to me.
    Working case using global transaction :
    =====================
    a) initial context
    T1 have 1 child(T2)
    T3 have 0 child
    b) actions
    moving T2 to T3 with global transaction
    c) result
    T1 have 0 child
    T3 have 1 child(T2)
    =====================
    This is very problematic and strange to me, so any help is welcomed...
    Thomas

  • Many-Many Relation

    I'm using Sun ONE AS 7 for deploying an EJB jar containing several entitys with relations.
    I can use the methods set<Relation> and I can see the new data in the database system, it looks goods even the tables using for the many-many relations.
    But when I use the get<Relation> method and I try to access the Collection that returns that method I always found the next error:
    WARNING: CORE3283: stderr: java.lang.IllegalStateException
    WARNING: CORE3283: stderr:      at com.sun.jdo.spi.persistence.support.ejb.cmp.E
    JBHashSet.assertInTransaction(EJBHashSet.java:352)
    WARNING: CORE3283: stderr:      at com.sun.jdo.spi.persistence.support.ejb.cmp.E
    JBHashSet.iterator(EJBHashSet.java:295)
    ...I've traced the SQL statement executed by the S1AS and that statement works fine, so the problem is not in the DB system.
    Thanks in advance for your help.

    Hello,
    I got the same problem wit a 1:* Relation, but I can't find an error in my Transactions. All of them are marked as required and I use Container Managed Persistence.
    here is my error code:
    Caught an exception:
    java.lang.IllegalStateException
    at com.sun.jdo.spi.persistence.support.ejb.cmp.EJBHashSet.a
    EJBHashSet.java:339)
    at com.sun.jdo.spi.persistence.support.ejb.cmp.EJBHashSet.s
    t.java:192)
    at util.EmployeeDetails.toString(EmployeeDetails.java:142)
    at clients.TimeRecordClient.main(TimeRecordClient.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Meth
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethod
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegati
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Ut
    5)
    at com.sun.enterprise.appclient.Main.<init>(Main.java:420)
    at com.sun.enterprise.appclient.Main.main(Main.java:92)
    Maybe someone could help me....

  • Many-to-many relation

    Hi,
    There is a many-to-many relation defined for the following tables:
    Table T_PRICEAFFECTOR
    Name Type
    NAME VARCHAR2(100)
    ISACCUMULATIVE NUMBER(1)
    RATE NUMBER(10,10)
    PRICEAFFECTOR_ID NOT NULL NUMBER(10)
    CATALOG_ID NOT NULL NUMBER(10)
    UNITTYPE NOT NULL NUMBER(1)
    and
    Table T_PRICEAFFECTINGCHAIN
    Name Type
    PRICEAFFECTINGCHAIN_ID NOT NULL NUMBER(10)
    NAME VARCHAR2(100)
    ISDEFAULTFORSTORE NUMBER(1)
    CATALOG_ID NOT NULL NUMBER(10)
    There is also a third table defining the many-to-many relation:
    TABLE T_PRICEAFFECTORTOCHAIN
    Name Type
    PRICEAFFECTOR_ID NOT NULL NUMBER(10)
    PRICEAFFECTINGCHAIN_ID NOT NULL NUMBER(10).
    The classes defined are as follows:
    public class PriceAffectorsChain
         private Catalog catalog;
         private long priceAffectorsChainId;
         private String name;
         private boolean isDefaultForStore;
         private Collection priceAffectors = new HashSet ();
         private Collection products = new HashSet ();
    public class PriceAffector
         private long priceAffectorId;
         private long isAccumulative;
         private String name;
         private double rate;
         private Catalog catalog;
         private int unitType;
         private Collection priceAffectorsChains = new HashSet ();
    and these are defined in the jdo descriptor in the following way:
    <class name="PriceAffector" identity-type="application"
    objectid-class="jp.telewave.platpark.eis.dao.pk.PriceAffectorPK">
         <extension vendor-name="kodo" key="lock-column" value="none"/>
         <extension vendor-name="kodo" key="class-column" value="none"/>
         <extension vendor-name="kodo" key="table" value="T_PRICEAFFECTOR"/>
         <field name="priceAffectorId" primary-key="true">
              <extension vendor-name="kodo" key="data-column"
    value="PRICEAFFECTOR_ID"/>
         </field>
         <field name="isAccumulative">
              <extension vendor-name="kodo" key="data-column" value="ISACCUMULATIVE"/>
         </field>
         <field name="name">
              <extension vendor-name="kodo" key="data-column" value="NAME"/>
         </field>
         <field name="rate">
              <extension vendor-name="kodo" key="data-column" value="RATE"/>
         </field>
         <field name="unitType">
              <extension vendor-name="kodo" key="data-column" value="UNITTYPE"/>
         </field>
         <field name="catalog">
              <extension vendor-name="kodo" key="catalogId-data-column"
    value="CATALOG_ID"/>
         </field>
         <field name="priceAffectorsChains">
              <collection element-type="PriceAffectorsChain"/>
              <extension vendor-name="kodo" key="read-only" value="true"/>
              <extension vendor-name="kodo" key="inverse" value="priceAffectors"/>
              <extension vendor-name="kodo" key="table"
    value="T_PRICEAFFECTORTOCHAIN"/>
              <extension vendor-name="kodo" key="priceAffectorId-ref-column"
    value="PRICEAFFECTOR_ID"/>
              <extension vendor-name="kodo" key="priceAffectorsChainId-data-column"
    value="PRICEAFFECTINGCHAIN_ID"/>
         </field>
    </class>
    <class name="PriceAffectorsChain" identity-type="application"
    objectid-class="jp.telewave.platpark.eis.dao.pk.PriceAffectorsChainPK">
         <extension vendor-name="kodo" key="lock-column" value="none"/>
         <extension vendor-name="kodo" key="class-column" value="none"/>
         <extension vendor-name="kodo" key="table" value="T_PRICEAFFECTINGCHAIN"/>
         <field name="priceAffectorsChainId" primary-key="true">
              <extension vendor-name="kodo" key="data-column"
    value="PRICEAFFECTINGCHAIN_ID"/>
         </field>
    <field name="catalog">
              <extension vendor-name="kodo" key="catalogId-data-column"
    value="CATALOG_ID"/>
         </field>
         <field name="name">
              <extension vendor-name="kodo" key="data-column" value="NAME"/>
         </field>
         <field name="isDefaultForStore">
         <extension vendor-name="kodo" key="data-column"
    value="ISDEFAULTFORSTORE"/>
         </field>
         <field name="priceAffectors">
              <collection element-type="PriceAffector"/>
              <extension vendor-name="kodo" key="read-only" value="false"/>
              <extension vendor-name="kodo" key="inverse"
    value="priceAffectorsChains"/>
              <extension vendor-name="kodo" key="table"
    value="T_PRICEAFFECTORTOCHAIN"/>
              <extension vendor-name="kodo" key="priceAffectorsChainId-ref-column"
    value="PRICEAFFECTINGCHAIN_ID"/>
              <extension vendor-name="kodo" key="priceAffectorId-data-column"
    value="PRICEAFFECTOR_ID"/>
         </field>
         <field name="products">
         <collection element-type="Product"/>
         <extension vendor-name="kodo" key="inverse" value="priceAffectorsChain"/>
         </field>
    </class>
    =============================================================
    Ok. The problem with the mapping is that it works only one way. What I
    mean is that when I try to add new PriceAffectorsChain with many
    PriceAffector objects only the PriceAffectorsChain object is being
    persisted, and none of the PriceAffectors are persisted in the
    many-to-many table (T_PRICEAFFECTORTOCHAIN), even when the read-only
    extensions are set.
    That was not the case when I tried to add new PriceAffector with many
    PriceAfffectorsChain - everything worked.
    Any Ideas?
    -Ivan

    Abe White wrote:
    When you have a two-sided relation, you need to be maintaining both sides
    of the relation at all times. Whenever an A is added to a B, the B must
    be added to the A as well. Keep your in-memory Java objects consistent
    (just as if they were not persistent), and JDO will take care of the rest.Abe White wrote:
    When you have a two-sided relation, you need to be maintaining both sides
    of the relation at all times.
    Whenever an A is added to a B, the B must
    be added to the A as well. Keep your in-memory Java objects consistent
    (just as if they were not persistent), and JDO will take care of the rest.Ok. I agree.
    I think that I'm doing this or maybe I'm wrong. Below is the code that
    adds new price affectors chain with collection of price affectors (all of
    them already persistent). Each of the price affectors is being looked up
    and is consistent (this is what getObjectById is doing, isn't it?) and
    then the price affector chain is being persisted.
    =================================================================
    PersistenceManager pm = null;
    PriceAffectingChain newPriceAffectorsChain = null;
    HashSet priceAffectors = null;
    try {
    pm = persistenceManagerFactory.getPersistenceManager();
    // getting the catalog object
    long catalogId = priceAffectorsChain.getCatalog().getCatalogId();
    CatalogPK catalogPK = new CatalogPK(catalogId);
    Catalog newPriceAffectorsChainCatalog =
    (Catalog)pm.getObjectById(catalogPK, true);
    // making new price affecting chain
    newPriceAffectorsChain = new PriceAffectingChain(
    BeanHelper.getNextSequence(DBObjects.SEQ_PRICEAFFECTINGCHAIN),
    priceAffectorsChain.getName(),
         priceAffectorsChain.getIsDefaultForStore(),
         newPriceAffectorsChainCatalog);
    // retrieval of price affector objects for this chain
    System.out.println("the size of the price affectors is: " +
    priceAffectorPKs.length);
    if (priceAffectorPKs != null && priceAffectorPKs.length > 0) {
         priceAffectors = new HashSet(priceAffectorPKs.length);
    for (int i = 0; i < priceAffectorPKs.length; i++) {
              PriceAffectorPK currentPAPK = priceAffectorPKs;
              PriceAffector currentPA = (PriceAffector)pm.getObjectById(currentPAPK,
    true);
              priceAffectors.add(currentPA);
              System.out.println("The " + currentPA.getName() + " price affector was
    added");
    if (priceAffectors == null) {
         priceAffectors = new HashSet();
    System.out.println("size of priceAffectors: " +
    priceAffectors.size());
    newPriceAffectorsChain.setPriceAffectors(priceAffectors);
    pm.makePersistent(newPriceAffectorsChain);
    } catch {
    ===========================================================
    The problem is that the presistence works only for the table of
    PriceAffectingChain obejct and not for the relation table. I tried on
    purpose to add new price affectors with collection of price affecting
    chains and it worked for both tables (the one for PriceAffector object and
    the relation table.
    I have no idea what I can try next. Any advice or help are welcomed.
    Thanks.
    -Ivan

  • Many-to-Many relation sample in ADF

    I have a requirement to implement a screen
    Three tables 1) Users 2) Access 3) Documents
    The Access table contains both the references DocId and UserId and acts as the intersection table.
    Users table is related to Documents through the Access table which acts as the intersection table and vice versa. I need to create a screen gui which will show all the documents a user has. Secondly also show all the users who has permission to a particular document. Is there any sample adf application which implements a simple many-to-many relation.
    I am planning to create three entity objects - UsersEO, AccessEO, DocumentsEO
    two view objects - UsersVO and DocumentsVO
    one view link -UsersDocumentVL
    Also which GUI components is best suited to address this. How many Entity Objects, View Objects and View Link should I create. Any simple sampe will help.
    Regards
    Thomas

    Thomas,
    There are of course many ways to implement your requirement. Try this exercise... forget about ADF for a moment; put your computer away (well, finish reading this first ;) ). Grab a pencil and paper.. assuming you could do anything, how would you like the screen to work? Draw it out on a piece of paper and describe how it works. You've just created a rudimentary specification. Now, come back to this thread and describe your specification - perhaps then we can help you implement your spec using ADF (or at least tell you "not possible" and describe why).
    Best,
    John

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to create one to many relation database based on existing Tables?

    Let say I have got 10 tables. Out of these 10 tables one table is used to navigate to other tables and at the some time providing some useful information. Therefore other 9 Tables have the identical structure.
    The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?

    Hello,
    >>The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?
    I do not quite understand what you ask and I doubt if Entity Framework supports this scenario, since you mentions these tables already exist, after importing them to the designed windows, we cannot modify them or it would throw an error shows the database
    and model is mismatched.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Many small problems in Mavericks

    When user experience many small problem in daily work, I feel the design is failed.
    Memory management has a lot of problem, I feel my macbook is abnormal slow after I upgraded to Mavericks. Sometime, I need to wait for several sec to get what I want.
    I think this problem is extreme important for OS.
    When I want to start a probelm, click once, no response, click twice, pop-up 2 times after 5 sec.
    Then i change my way of work, clock one time, work on other task. 5 sec later, multi desktop switch the desktop to the starting program. Then, I don't know what I was doing.
    Another is sound problem, sound doesn't work sometime and need some kind of procedure to get it back.
    Please don't ask me do something to solve the problem everytime when it happen. It is OS task to work it properly.
    Whatever how many great feature you added is meaningless if user daily experience is bad.

    1. This procedure is a diagnostic test. It changes nothing, for better or worse, and therefore will not, in itself, solve your problem.
    2. If you don't already have a current backup, back up all data before doing anything else. The backup is necessary on general principle, not because of anything in the test procedure. There are ways to back up a computer that isn't fully functional. Ask if you need guidance.
    3. Below are instructions to run a UNIX shell script, a type of program. All it does is to gather information about the state of your computer. That information goes nowhere unless you choose to share it on this page. However, you should be cautious about running any kind of program (not just a shell script) at the request of a stranger on a public message board. If you have doubts, search this site for other discussions in which this procedure has been followed without any report of ill effects. If you can't satisfy yourself that the instructions are safe, don't follow them.
    Here's a summary of what you need to do, if you choose to proceed: Copy a line of text from this web page into the window of another application. Wait for the script to run. It usually takes a couple of minutes. Then paste the results, which will have been copied automatically, back into a reply on this page. The sequence is: copy, paste, wait, paste again. Details follow.
    4. You may have started the computer in "safe" mode. Preferably, these steps should be taken in “normal” mode. If the system is now in safe mode and works well enough in normal mode to run the test, restart as usual. If you can only test in safe mode, do that.
    5. If you have more than one user, and the one affected by the problem is not an administrator, then please run the test twice: once while logged in as the affected user, and once as an administrator. The results may be different. The user that is created automatically on a new computer when you start it for the first time is an administrator. If you can't log in as an administrator, test as the affected user. Most personal Macs have only one user, and in that case this section doesn’t apply.
    6. The script is a single long line, all of which must be selected. You can accomplish this easily by triple-clicking  anywhere in the line. The whole line will highlight, though you may not see all of it in your browser, and you can then copy it. If you try to select the line by dragging across the part you can see, you won't get all of it.
    Triple-click anywhere in the line of text below on this page to select it:
    PATH=/usr/bin:/bin:/usr/sbin:/sbin; clear; Fb='%s\n\t(%s)\n'; Fm='\n%s\n\n%s\n'; Fr='\nRAM details\n%s\n'; Fs='\n%s: %s\n'; Fu='user %s%%, system %s%%'; PB="/usr/libexec/PlistBuddy -c Print"; A () { [[ a -eq 0 ]]; }; M () { find -L "$d" -type f | while read f; do file -b "$f" | egrep -lq XML\|exec && echo $f; done; }; Pc () { o=`grep -v '^ *#' "$2"`; Pm "$1"; }; Pm () { [[ "$o" ]] && o=`sed '/^ *$/d; s/^ */   /' <<< "$o"` && printf "$Fm" "$1" "$o"; }; Pp () { o=`$PB "$2" | awk -F'= ' \/$3'/{print $2}'`; Pm "$1"; }; Ps () { o=`echo $o`; [[ ! "$o" =~ ^0?$ ]] && printf "$Fs" "$1" "$o"; }; R () { o=; [[ r -eq 0 ]]; }; SP () { system_profiler SP${1}DataType; }; id | grep -qw '80(admin)'; a=$?; A && sudo true; r=$?; t=`date +%s`; clear; { A || echo $'No admin access\n'; A && ! R && echo $'No root access\n'; SP Software | sed '8!d;s/^ *//'; o=`SP Hardware | awk '/Mem/{print $2}'`; o=$((o<4?o:0)); Ps "Total RAM (GB)"; o=`SP Memory | sed '1,5d; /[my].*:/d'`; [[ "$o" =~ s:\ [^O]|x([^08]||0[^2]8[^0]) ]] && printf "$Fr" "$o"; o=`SP Diagnostics | sed '5,6!d'`; [[ "$o" =~ Pass ]] || Pm "POST"; for b in Thunderbolt USB; do o=`SP $b | sed -En '1d; /:$/{s/ *:$//;x;s/\n//p;}; /^ *V.* [0N].* /{s/ 0x.... //;s/[()]//g;s/\(.*: \)\(.*\)/ \(\2\)/;H;}; /Apple|SCSM/{s/.//g;h;}'`; Pm $b; done; o=`pmset -g therm | sed 's/^.*C/C/'`; [[ "$o" =~ No\ th|pms ]] && o=; Pm "Thermal conditions"; o=`pmset -g sysload | grep -v :`; [[ "$o" =~ =\ [^GO] ]] || o=; Pm "System load advisory"; o=`nvram boot-args | awk '{$1=""; print}'`; Ps "boot-args"; d=(/ ""); D=(System User); E=; for i in 0 1; do o=`cd ${d[$i]}L*/L*/Dia* || continue; ls | while read f; do [[ "$f" =~ h$ ]] && grep -lq "^Thread c" "$f" && e=" *" || e=; awk -F_ '!/ag$/{$NF=a[split($NF,a,".")]; print $0 "'"$e"'"}' <<< "$f"; done | tail`; Pm "${D[$i]} diagnostics"; done; [[ "$o" =~ \*$ ]] && printf $'\n* Code injection\n'; o=`syslog -F bsd -k Sender kernel -k Message CReq 'GPU |hfs: Ru|I/O e|last value [1-9]|n Cause: -|NVDA\(|pagin|SATA W|ssert|timed? ?o' | tail -n25 | awk '/:/{$4=""; $5=""};1'`; Pm "Kernel messages"; o=`df -m / | awk 'NR==2 {print $4}'`; o=$((o<5120?o:0)); Ps "Free space (MiB)"; o=$(($(vm_stat | awk '/eo/{sub("\\.",""); print $2}')/256)); o=$((o>=1024?o:0)); Ps "Pageouts (MiB)"; s=( `sar -u 1 10 | sed '$!d'` ); [[ s[4] -lt 85 ]] && o=`printf "$Fu" ${s[1]} ${s[3]}` || o=; Ps "Total CPU usage" && { s=(`ps acrx -o comm,ruid,%cpu | sed '2!d'`); o=${s[2]}%; Ps "CPU usage by process \"$s\" with UID ${s[1]}"; }; s=(`top -R -l1 -n1 -o prt -stats command,uid,prt | sed '$!d'`); s[2]=${s[2]%[+-]}; o=$((s[2]>=25000?s[2]:0)); Ps "Mach ports used by process \"$s\" with UID ${s[1]}"; o=`kextstat -kl | grep -v com\\.apple | cut -c53- | cut -d\< -f1`; Pm "Loaded extrinsic kernel extensions"; R && o=`sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix\.cron)|org\.(amav|apac|calendarse|cups|dove|isc|ntp|post[fg]|x)/{print $3}'`; Pm "Extrinsic system jobs"; o=`launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)|\.[0-9]+$/{print $3}'`; Pm "Extrinsic agents"; o=`for d in {/,}L*/Lau*; do M; done | grep -v com\.apple\.CSConfig | while read f; do ID=$($PB\ :Label "$f") || ID="No job label"; printf "$Fb" "$f" "$ID"; done`; Pm "launchd items"; o=`for d in /{S*/,}L*/Star*; do M; done`; Pm "Startup items"; o=`find -L /S*/L*/E* {/,}L*/{A*d,Compon,Ex,In,Keyb,Mail/B,P*P,Qu*T,Scripti,Servi,Spo}* -type d -name Contents -prune | while read d; do ID=$($PB\ :CFBundleIdentifier "$d/Info.plist") || ID="No bundle ID"; [[ "$ID" =~ ^com\.apple\.[^x]|Accusys|ArcMSR|ATTO|HDPro|HighPoint|driver\.stex|hp-fax|\.hpio|JMicron|microsoft\.MDI|print|SoftRAID ]] || printf "$Fb" "${d%/Contents}" "$ID"; done`; Pm "Extrinsic loadable bundles"; o=`find -L /u*/{,*/}lib -type f | while read f; do file -b "$f" | grep -qw shared && ! codesign -v "$f" && echo $f; done`; Pm "Unsigned shared libraries"; o=`for e in DYLD_INSERT_LIBRARIES DYLD_LIBRARY_PATH; do launchctl getenv $e; done`; Pm "Environment"; o=`find -L {,/u*/lo*}/e*/periodic -type f -mtime -10d`; Pm "Modified periodic scripts"; o=`scutil --proxy | grep Prox`; Pm "Proxies"; o=`scutil --dns | awk '/r\[0\] /{if ($NF !~ /^1(0|72\.(1[6-9]|2[0-9]|3[0-1])|92\.168)\./) print $NF; exit}'`; Ps "DNS"; R && o=`sudo profiles -P | grep : | wc -l`; Ps "Profiles"; f=auto_master; [[ `md5 -q /etc/$f` =~ ^b166 ]] || Pc $f /etc/$f; for f in fstab sysctl.conf crontab launchd.conf; do Pc $f /etc/$f; done; Pc "hosts" <(grep -v 'host *$' /etc/hosts); Pc "User launchd" ~/.launchd*; R && Pc "Root crontab" <(sudo crontab -l); Pc "User crontab" <(crontab -l); R && o=`sudo defaults read com.apple.loginwindow LoginHook`; Pm "Login hook"; Pp "Global login items" /L*/P*/loginw* Path; Pp "User login items" L*/P*/*loginit* Name; Pp "Safari extensions" L*/Saf*/*/E*.plist Bundle | sed -E 's/(\..*$|-[1-9])//g'; o=`find ~ $TMPDIR.. \( -flags +sappnd,schg,uappnd,uchg -o ! -user $UID -o ! -perm -600 \) | wc -l`; Ps "Restricted user files"; cd; o=`SP Fonts | egrep "Valid: N|Duplicate: Y" | wc -l`; Ps "Font problems"; o=`find L*/{Con,Pref}* -type f ! -size 0 -name *.plist | while read f; do plutil -s "$f" >&- || echo $f; done`; Pm "Bad plists"; d=(Desktop L*/Keyc*); n=(20 7); for i in 0 1; do o=`find "${d[$i]}" -type f -maxdepth 1 | wc -l`; o=$((o<=n[$i]?0:o)); Ps "${d[$i]##*/} file count"; done; o=$((`date +%s`-t)); Ps "Elapsed time (s)"; } 2>/dev/null | pbcopy; exit 2>&-
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    7. Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign ($) or a percent sign (%). If you get the percent sign, enter
    exec bash
    in the window and press return. You should then get a new line ending in a dollar sign.
    Click anywhere in the Terminal window and paste (command-V). The text you pasted should vanish immediately. If it doesn't, press the return key.
    If you're logged in as an administrator, you'll be prompted for your login password. Nothing will be displayed when you type it. You will not see the usual dots in place of typed characters. Make sure caps lock is off. Type carefully and then press return. You may get a one-time warning to be careful. If you make three failed attempts to enter the password, the test will run anyway, but it will produce less information. In most cases, the difference is not important. If you don't know your password, or if you prefer not to enter it, just press return three times at the password prompt.
    If you're not logged in as an administrator, you won't be prompted for a password. The test will still run. It just won't do anything that requires administrator privileges.
    The test may take a few minutes to run, depending on how many files you have and the speed of the computer. A computer that's abnormally slow may take longer to run the test. While it's running, there will be nothing in the Terminal window and no indication of progress. Wait for the line "[Process completed]" to appear. If you don't see it within half an hour or so, the test probably won't complete in a reasonable time. In that case, close the Terminal window and report your results. No harm will be done.
    8. When the test is complete, quit Terminal. The results will have been copied to the Clipboard automatically. They are not shown in the Terminal window. Please don't copy anything from there. All you have to do is start a reply to this comment and then paste by pressing command-V again.
    If any private information, such as your name or email address, appears in the results, anonymize it before posting. Usually that won't be necessary.
    When you post the results, you might see the message, "You have included content in your post that is not permitted." It means that the forum software has misidentified something in the post as a violation of the rules. If it happens, please post the test results on Pastebin, then post a link here to the page you created.
    Note: This is a public forum, and others may give you advice based on the results of the test. They speak only for themselves, and I don't necessarily agree with them.
    Copyright © 2014 Linc Davis. As the sole author of this work, I reserve all rights to it except as provided in the Terms of Use of Apple Support Communities ("ASC"). Readers of ASC may copy it for their own personal use. Neither the whole nor any part may be redistributed.

  • JPA: Issue with loading One To Many relation

    Hi All,
    I have a One to Many relation mapped as below
    @Entity
    @Table(name="ACCOUNT_TABLE")
    public class UserAccount {
         // Attributes
         @Id
         @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="USER_SEQ")
         @SequenceGenerator(name="USER_SEQ", sequenceName="USERS_SEQ",allocationSize=1)
         @Column(name="CLIENT_ID")
         private Long clientId;
         @Column(name="USER_ID")
         private String userId;
         @OneToMany(fetch=FetchType.LAZY, mappedBy="userAccount")
         @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
         private List<UserRole> assignedRoles;
    @Entity
    @Table(name = "ROLE_TABLE")
    public class UserRole extends BaseEntity implements Serializable {
         private static final long serialVersionUID = -1651953276532642312L;
         @Id
         @Column(name = "USER_ID", length = 30, nullable=false, insertable=false, updatable=false)
         private String userId;
         @Column(name = "BUSINESS_CODE", length = 10, nullable=false, insertable=false, updatable=false)
         private String businessCode;
         @Column(name = "ROLE_NAME", length = 30, nullable=false, insertable=false, updatable=false)
         private String roleName;
         @ManyToOne()
         @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
         private UserAccount userAccount;
    As you may have noticed, the tables are not joined on the Primary key of parent. This is legacy schema and I have to work with it.
    Account and Role are joined by the USER_ID column. This I specified by providing JoinColumn.
    Then I have a DAO to retrieve the relation based on user id.
    public class UserAccountDAOJPAImpl UserAccountDAO{
         private static final String USER_ACCOUNT_BY_USERID = "select distinct ua " +
         "from UserAccount ua " +
         "left outer join fetch ua.assignedRoles ar " +
         "where ua.userId = ?1 ";
         public UserAccount findByUserName(String userName){          
              UserAccount userAccount=null;
              List<UserAccount> userAccounts =null;
         Query query = this.entityManager.createQuery(USER_ACCOUNT_BY_USERID);
         query.setParameter(1, userName.toUpperCase());
         userAccounts = query.getResultList();
         if(!userAccounts.isEmpty()) {
              userAccount=userAccounts.get(0);
              return userAccount;
    When I test this code ( for the user Id I used in test there are 11 roles )
    The SQL generated is correct, when I run the SQL in PL/SQL Developer, it returns the results as expected.
    But the DAO method above returns one UserAccount object with List of 11 UserRole objects as expected. But all of these 11 UserRole objects are same, where as the query returns 11 different roles.
    I couldn't figure out what I was doing wrong.
    Any help is appreciated.
    thanks,
    Raghavan

    @OneToMany(fetch=FetchType.LAZY, mappedBy="userAccount")
    @JoinColumn(name="USER_ID", referencedColumnName="USER_ID", insertable=false, updatable=false)
    private List<UserRole> assignedRoles;
    }What do you get when you remove this @JoinColumn annotation? It shouldn't be necessary. (user_id seems a little suspect as the join column name by the way, I would have expected role_id here...)

  • Primary one-to-many relation

    What is the best practice to identify the primary entity in a one-to-many relation?
    Lets asume the following:
    I have persons. (Table: PERSON, Primary Key: PERSON_ID)
    I have contact points (Table: CONTACT_POINTS, Foreign Key to PERSON_ID)
    In the E-Business Suite we have a field PRIMARY_FLAG on the CONTACT_POINTS table. This is either Y or N. Now it is upon the application, to verify that only one primary contact point is set. But there is no check in the database. You can have 2 lines, with primary_flag = 'Y'.
    This would make it heavy to do a simple select as:
    SELECT p.first_name, p.last_name, cp.phone_number FROM PERSON p, CONTACT_POINTS cp WHERE cp.PERSON_ID(+) = p.PERSON_ID AND cp.PRIMARY_FLAG(+) = 'Y'
    Because if you have, by mistake, 2 lines with PRIMARY_FLAG = 'Y', you would get 2 result lines in the query above, which is not wanted.
    A second way would be to have the PRIMARY_FLAG field is filled either with Y or NULL. In addition I can set a unique constrain over PERSON_ID and PRIMARY_FLAG and the database will block every try to add a second Y for one person. In that way I can be sure that I either have a primary contact point or I do not have one. So the query will result the same number of lines as there are in the PERSON table. BUT: whenever I go that way, I have to verify my application logic, that every change on the primary flag must set the old primary entry off and then insert or update the new primary entry.
    Which one is the best way, in practice? Are there other solutions? What are advantages ?
    Best Regards
    Alexander

    You can create unique function based index on your CONTACT_POINTS table as follows:
    (person_id, case when primary_flag = 'Y' then primary_flag else null end)
    So as soon as you'll insert another row with Y, you'll get error, but with other values like N, all will be OK.
    And yes - I think it is worth to check data integrity in DB :)
    Gints Plivna
    http://www.gplivna.eu

Maybe you are looking for