Cascading problems

Hi,
We are testing some JPA code and are having problems with the cascading behaviour of our test code.
Firstly, we have a main Person bean with the following attributes and is the owning side of the two relationships:
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "firstname")
private String firstname;
@Column(name = "lastname")
private String lastname;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, targetEntity = OccupationJpaImpl.class)
@JoinColumn(name = "occupation_id")
private Occupation occupation;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, targetEntity = BeverageJpaImpl.class)
@JoinTable(name = "person_beverage", joinColumns = { @JoinColumn(name = "person_id") }, inverseJoinColumns = { @JoinColumn(name = "beverage_id") })
private Set<Beverage> beverages;Each of the non-owning sides are set up as follows:
Beverage:
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "description")
private String description;
@Column(name = "alcoholic")
private Boolean alcoholic;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "beverages", targetEntity = PersonJpaImpl.class)
private Set<Person> people;
Occupation:
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "description")
private String description;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "occupation", targetEntity = PersonJpaImpl.class)
private Set<Person> people;We have a few tests of which one works and the rest fail:
1 - If we remove a Beverage from a collection of beverages belonging to a Person and merge the Person then the underlying join table has the appropriate mapping record removed which we want.
2 - If we remove a Person from a collection of people belonging to a Beverage and merge the Beverage then the underlying join table does not have the appropriate mapping record removed.
3 - If we delete an Occupation then the associated people, and any of their associated records, are not deleted but rather an attempt is made to insert a null into the occupation_id column of the underlying person table. This does not happen if there is no many-to-many relationship on Person to Beverage, then the people are deleted.
Any explanation as to why 2 and 3 do not work as expected would be greatly appreciated.
Regards,
Chris.

I am no JPA expert but I did have a similar problem recently. My problem was having the cascade setting in both the owning and non-owning entity classes. When I merged a non-owning entity it would cascade it's current data up into the owning entity which in my case would overwrite data I had just set and merged in the owning entity.
I believe you need to remove the cascade setting in your non-owning entity classes and / or know exactly what is set in each property of your non-owning entities before you attempt to merge them so you will know what table modifications you can expect to see.
In my particular case cascading in both directions was causing my problems.
Hope this helps.

Similar Messages

  • RT31P2/WRT350N Cascading Problems

    Problem: Using the WRT350N as the main router connected to the Motorola Cable modem, I have now added the RT31P2 for phone service. I am trying to establish only one subnet, so i have disabled NAT on the RT31 and connected the RJ45 to Numbered ports on both WRT and RT3 routers, this gives me DHCP from WRT350 on all the ports and routers - PC's work great and Internet access is working fine... Issue is the Phone Services is not working, looks like the RT31p2 is not getting a DHCP address from the WRT350n so the voice registration is not working properly.
    Do i need to work with Static Routing? -- All of this networking is confusing and i have not figured out what is needed... just a side note.. i can plug the RT31P2 WAN Plug to a numbered plug on the WRT350 and i get phone access just fine... but the problem with this is that the routing of DHCP addresses to the numbered ports on the RT31 no longer work...
    Sorry for the long post... thanks for any help you can provide...
    Message Edited by Sleadrider on 04-09-2008 01:16 AM

    the RT31p2 eeds the WAN conection to get the voice up and running. I believe you do not need to do static routing on this. BUt you will need to disable the NAT on the router " Advance routing" make sure to disable the DCHP as well on the rt31p2. with the NAT disabled on the router. then you should be able to recieve IP from the wrt350n and get the voice running also.

  • Yosemite and mail - BIG problems with memory leak

    Our small company has had significant problems since upgrading (?) to Yosemite, which by all we could glean from Apple would be a relatively bug free install. At random times, usually while composing an e-mail, the mail program will just spike in memory consumption, going from a couple hundred Mb of RAM consumption to over 70 Gb in just 3-5 minutes. This obviously causes the entire machine to come to a standstill and the mail process needs to be killed. A cascading problem is that when this happens any other programs will also become non-responsive, and they also will need to be killed, often at the loss of work. I've talked with the support people at Apple and disappointingly they seem to be unaware that this is an issue, or more likely they are aware of it (I mean, just do a search of "Yosemite mail memory" and see what you get) and want to downplay that the release has been a HUGE failure for MANY people. After about 20 of these application memory events since upgrading over this past weekend at our company I would like to see where Apple is on fixing this. BTW Apple, your user base is fairly sophisticated with computing, and having your online assistants continue to try and point the problem at the users - who are all having the EXACT SAME ISSUE - is alienating your user base. I've been using Apple for over 20 years and this is the worst release you've ever had. I think you're well on your way to becoming Microsoft in 1994, we need the old Apple company back.

    I have the same problem and after a few days I am thinking seriously about abandoning Apple mail and .... going back to Outlook, I do not like MS, but may not have another option. Any suggestions.
    I am amazed that Apple does not give any information about the problem. It does look like they are loosing their touch and appear to be following the Microsoft and Blackberry path.
    Within a small company like mine, another few days of this and it will be impossible to keep it.
    Hate to say it, but for the first timewith Apple I miss the old OS, it did not look as good but at least it worked..

  • Top Ten Things a Motion Graphics Artist should know...

    As many of you regulars know, I'm writing a book on Motion. As well as the projects, this book has Interlude Essays - that is a couple of pages of writing on related motion graphics topics. For instance, one is "Where do I get my ideas?" another is "How to speed up Motion", etc...
    I thought I'd include one on Things a Motion Graphics Artist should know. And I'm open to suggestions. Got any tips? What do YOU think a Motion Graphics Artist should know? Please contribute as many or as few as you like.
    I can't credit you in the book, but I will thank you en masse...
    While this thread is not strictly within the confines of the technical troubleshooting this forum exists to serve, I hope the Powers That Be don't pull it, because it could be an excellent resource for all who frequent this forum.
    Many thanks,
    Patrick

    Yes - that reminds me of a quasi-questionable practice I sometimes employed as an editor of music videos that I and other editors called "The Velcro Dog".
    It goes back to the fact that you never wanted to turn in a "perfect" edit on the first pass. In fact, I could count on one hand the number of times that I turned in an edit that the record label said "perfect, don't change a frame". Maybe it's human nature to justify their jobs, but inevitably, those in charge of approval would have to make some comment, request some change...
    If your cut was perfect, often these changes would be for the worse, so sometimes it paid to add an obvious flaw to the edit that wasn't hard to change - thus the Velcro Dog, something bad that could be easily torn off. It might be as simple as a line that was out of sync - or maybe a shot where the lead singer had his hair in his mouth, or a story shot that was out of place. This gave those in charge something to focus on that you could fix without causing the cascading problems that more complex changes might require.
    It was also something that you could change without problem if no one picked up on it.
    But WOE to you if someone in the chain of Artist, Video Commissioner, Management, A&R, Marketing, etc... decided they actually liked your little velcro dog... Then you had to live with seeing it on TV like that.
    Patrick

  • DVD vs. Screensaver--a battle

    I've got an iBook G4, Mac OS X 10.3.9, and my DVD player is version 4.0.
    For the last 18 months, since I got my laptop, I've watched movies on it. Tonight, for the first time, the screensaver began coming on as the movie was playing. I have had my screensaver Preference set at four minutes--have not changed it since setting it 18 months ago--and it was interrupting the movie after four minutes. I had to click the screen to get the movie back, but the saver would come on again four minutes later.
    The sound was unaffected, if that provides any clues as to what is and is not involved.
    I could go in and set the screen saver Preference to "Never," but I WANT the screen saver to come on after four minutes when I'm working at the computer and have to step away for awhile. Also, it's inconvenient to have to go in and reset the Preferences every single time I stop or start playing a DVD.
    So, 1.) I'm wondering what the problem is, 2.) Is this a symptom of cascading problems, and of course 3.) how can I fix this so it's functioning normally again, i.e., not coming on at all while the DVD is playing. Anyone have ideas? Thanks. Erin S.

    Not really sure if this will help, but it couldn't hurt. Try resetting the PRAM. Go here for instructions:
    http://docs.info.apple.com/article.html?artnum=2238
    If that doesn't work, try resetting the PMU. Go here:
    http://docs.info.apple.com/article.html?artnum=14449
    Good luck,
    Susan

  • Problem with "Row-specific or Cascading Lists in Table Layout"

    Hello, friends!
    I have read article "Row-specific or Cascading Lists in Table Layout" written by Steven Davelaar. I have maked several table layouts with this technique and it worked fine.
    But now I have one problem, and this problem is very strange. One of VOs for which I use this table layouts throw exception after commit changes on first LOV attribute (Deptno). First time it was error
    (oracle.jbo.ReadOnlyAttrException) JBO-27008: for atribute mgrList
    at oracle.jbo.AttrValException.<init>(AttrValException.java:112)
         at oracle.jbo.ReadOnlyAttrException.<init>(ReadOnlyAttrException.java:40)
         at oracle.jbo.server.ViewRowImpl.setAttribute(ViewRowImpl.java:815)
         at oracle.jbo.jbotester.JboTesterUtil.setData(JboTesterUtil.java:173)
    Then I setted updateable property of MgrList attribute to always and now i have this error:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:java.util.List with value:[{}]
         at oracle.jbo.domain.TypeFactory.get(TypeFactory.java:721)
         at oracle.jbo.domain.TypeFactory.getInstance(TypeFactory.java:85)
    I don't know why, but all worked fine yestarday. And same code works fine for another VOs. And article Test application works fine too.
    Help me, please.
    Thank you.

    <table id="OsnovaniyaPrikazEnd" model="${jhsTableBindings.OsnovaniyaPrikazEnd_1B}" detailDisclosure="${uix.eventResult.detailData}" partialRenderMode="multiple" partialTargets="messageBox _uixState " proxied="true" alternateText="${nls.NO_ROWS_FOUND}" width="50%" rendered="${bindings.newGroup_end2Iterator.findMode!='true'}">
    <tableFormat tableBanding="rowBanding"/>
    <contents>
    <formValue value="${uix.current.rowKeyStr}" name="rowKeyStr" id="${ui:concat('OsnovaniyaPrikazEnd:rowKeyStr:',uix.current.tableIndex)}"/>
    <column>
    <columnFormat displayGrid="true" cellNoWrapFormat="true" columnDataFormat="numberFormat"/>
    <columnHeader>
    <sortableHeader model="${ctrl:createSortableHeaderModel(bindings.OsnovaniyaPrikazEnd,'Id')}" text="Id" required="yes"/>
    </columnHeader>
    <contents>
    <messageTextInput id="${ui:concat('OsnovaniyaPrikazEnd:Id:',uix.current.tableIndex)}" model="${ui:cond(uix.current.isNewRow,null,uix.current.newGroup_end2Id)}" text="${uix.current.OsnovaniyaPrikazEndId}" name="Id" promptAndAccessKey="&Id" rows="1" maximumLength="1" columns="1">
    <onSubmitValidater>
    <decimal/>
    </onSubmitValidater>
    </messageTextInput>
    </contents>
    </column>
    <column>
    <columnFormat displayGrid="true" cellNoWrapFormat="true" columnDataFormat="numberFormat"/>
    <columnHeader>
    <sortableHeader model="${ctrl:createSortableHeaderModel(bindings.OsnovaniyaPrikazEnd,'IdPrikaz')}" text="IdPrikaz"/>
    </columnHeader>
    <contents>
    <messageTextInput id="${ui:concat('OsnovaniyaPrikazEnd:IdPrikaz:',uix.current.tableIndex)}" model="${ui:cond(uix.current.isNewRow,null,uix.current.newGroup_end2IdPrikaz)}" text="${uix.current.OsnovaniyaPrikazEndIdPrikaz}" name="IdPrikaz" promptAndAccessKey="&IdPrikaz" rows="1" maximumLength="1" columns="1">
    <onSubmitValidater>
    <decimal/>
    </onSubmitValidater>
    </messageTextInput>
    </contents>
    </column>
    <column>
    <columnFormat displayGrid="true" cellNoWrapFormat="true" columnDataFormat="numberFormat"/>
    <columnHeader>
    <sortableHeader model="${ctrl:createSortableHeaderModel(bindings.OsnovaniyaPrikazEnd,'IdOsnovanie')}" text="&#1053;&#1072; &#1086;&#1089;&#1085;&#1086;&#1074;&#1072;&#1085;&#1080;&#1080;"/>
    </columnHeader>
    <contents>
    <messageChoice id="${ui:concat('OsnovaniyaPrikazEnd:IdOsnovanie:',uix.current.tableIndex)}" model="${ui:cond(uix.current.isNewRow,null,uix.current.IdOsnovanie)}" name="IdOsnovanie" promptAndAccessKey="&IdOsnovanie" selectedValue="${uix.current.newGroup_end2IdOsnovanie}">
    <contents childData="${jhsTableBindings.Osnovaniya_not_viewVO_1T.rangeSet}">
    <option value="${uix.current.Id}" text="${uix.current.Text}"/>
    </contents>
    <primaryClientAction>
    <firePartialAction event="whenListChanged" formSubmitted="true" unvalidated="true" targets="${ui:cond(uix.current.isNewRow,'OsnovaniyaPrikazEnd', 'OsnovaniyaPrikazEnd')}"/>
    </primaryClientAction>
    </messageChoice>
    </contents>
    </column>
    <column>
    <columnFormat displayGrid="true" cellNoWrapFormat="true" columnDataFormat="numberFormat"/>
    <columnHeader>
    <sortableHeader model="${ctrl:createSortableHeaderModel(bindings.OsnovaniyaPrikazEnd,'IdMoves')}" text="IdMoves"/>
    </columnHeader>
    <contents>
    <messageChoice rendered="${uix.current.ListLength>'1'}" id="${ui:concat('OsnovaniyaPrikazEnd:IdMoves:',uix.current.tableIndex)}"
    model="${ui:cond(uix.current.isNewRow,null,uix.current.OsnovaniyaPrikazEndIdMoves)}" name="IdMoves" promptAndAccessKey="&IdMoves"
    selectedValue="${uix.current.newGroup_end2IdMoves}">
    <contents childData="${uix.current.MovesList.inputValue}">
    <option value="${uix.current.Id}" text="${uix.current.Fam1}"/>
    </contents>
    </messageChoice>
    </contents>
    </column>
    <column>
    <columnFormat displayGrid="true" columnDataFormat="iconButtonFormat"/>
    <columnHeader>
    <text text="&#1059;&#1076;&#1072;&#1083;&#1080;&#1090;&#1100;?"/>
    </columnHeader>
    <contents>
    <checkBox name="deleteRow" value="ok"/>
    </contents>
    </column>
    </contents>
    </table>
    Thank you.

  • Problem with cascade delete and remove bean

    I am working with two entity beans that map to two tables that have a foreign key relationship. Table B has a foreign key to A and in the database that foreign key is set for cascaded updates and cascaded deletes.
    The problem occurs when the the sytem first tries to remove bean 1 (mapped to table A) and then remove bean 2 (mapped to B) where bean 2 is associated with bean 1 with a foreign key relationship. The first remove works but then when it tries to remove bean 2 it throws a very ugly "CORBA TRANSACTION_ROLLEDBACK 9998" Maybe exception. My guess is that the reason is because bean 2's reocrd in the database was deleted when bean 1 was removed but the 'bean object' was not removed from the container.
    When I go into our Application Server and look at how it see's the tables, it show the wrong relationship. It shows a restrict delete and a restrict update realationship.
    My question is, am I wrong to think that this is a application server problem or a configuration problem? It seems to me that attempting to remove a non-existant record should not cause an error. It won't cause any SQL exceptions. Is this a flawed viewpoint? As a work around I made sure that the dependent records are deleted first but it kind of defeats the point of cascaded deletes.
    We have a limited number of support calls, should I use one or am I at fault here?

    If the database removes the record from the second
    table, why is the system trying to remove it once
    again? You should try to remove an entity from a
    single place, should it be the database or the
    application. Don't try to remove it twice.
    Regards,
    DimitarI could do this but it is a huge pain in my ass. The problem is that you might want to remove the dependent bean without removing it's parent. The object structure is a little questionable, I'll admit that. It is, as they say, the eleventh hour and I can't really change that now.
    The way this work is that the server gets a list of objects marked either as new, modified, or deleted. It then relates those changes back to the database.
    In this case we have two lists(which makes me realize where the class structure sucks.) In order to do what you suggest I would have to get all the deleted parent objects and then search all the deleted child objects for ones that have the parent's key in them.
    It would be prefferable to fix the class structure but again this is not an option.
    Anyone want to answer the question I asked?

  • Problem in cascading the Prompt..

    Hi Guru's,
    I need your expert advice on problem related to Prompt.
    I have 5 columns in one Prompt which belong to different dimension from same subject area which are joined from Fact table.
    Report month is from Buisness month table and Reportdate is from TimeDim which is snow flacked.
    rest A,B and C dim are joined with time Dim from Fact table.
    ReportMonth>> ReportDate>>ADim>>BDim>>CDim
    Only Report date is Constrain rest all dont require cascading.
    In mine Prod Env. when i select A B and C prompt the Reportdate is getting cascaded and the logical query has all paramteres i.e. Reportmonth, ADim,BDim and CDim in logical sql but when i see the physical query only A,B and C are getting passed to the database but ReportMonth is not passed which is an calculated column in RPD.
    But in mine local or Dev env the Physical query is passing all the parameter i.e Report month,A,B,C to the database.
    Because of this am facing performace issue while selecting the Prompt.
    Am on production now so not ina stage to change the RPD and bring all the dimension in one LTS.:(
    Any query pls let me know.
    Any help would highly be appriciated.
    Cheers,
    Rajeev

    hi,
    I m using following code for selecting Countries
    public List getSelectedCountries() {
    if (selectedCountries == null || refreshSelectedList) {
    selectedCountries = attributeListForIterator("EmployeeMapCountryCity2", "CountryId");
    return selectedCountries;
    That is working but
    And same code is using for  selecting cities, it's not working
    public List getSelectedCities() {
    if (selectedCities == null || refreshSelectedList) {
    selectedCities = attributeListForIterator("EmployeeMapCountryCity2", "CityId");
    return selectedCities ;
    Above method won't get the value of selected cities
    please help me.
    Regards
    Abhijeet
    Edited by: AbhijeetPS on Jan 31, 2013 4:49 PM
    Edited by: AbhijeetPS on Jan 31, 2013 4:58 PM
    Edited by: AbhijeetPS on Jan 31, 2013 4:59 PM

  • Migration Microsoft SQL Sever 2005 to Oracle 11g cascade on delete problem

    Hi, I'm trying to migrate a sql server 2005 database to oracle 11g version with the lastest version of Oracle SQL Developer. All works fine but there is a little thing that I can't migrate. I have a few tables in the sql server database that has cascade on delete but I can't migrate this through Oracle Sql Developer.
    I know that Oracle database server supports it, then I can manually change the resulting database creation sql script but I'd like to know how I can do it with Oracle Sql Developer.
    Thanks in advance :)

    Hello,
    sorry for the delay.
    Even after some more research I couldn't find this problem described anywhere. I can confirm your observations, the problem is easy to reproduce. Thus I reported it to SQL Developer development as this looks like a bug.
    One workaround is to edit the generated DDL script and to add the ON DELETE CASCADE clause to the ALTER TABLE statement. If you don't like that: apply the scripts as they are and finish the migration. Then, in SQL Developer, right-click the table in your Oracle RDBMS schema, and click on Edit. In the pop-up window, select "Foreign Key". Then, in the lower right corner, there appears a small scroll-down menu where you can change the delete option from RESTRICT to CASCADE.
    Best regards
    Wolfgang

  • Problem in cascade-delete

    I've using cascade delete for delete rows from two entity beans.......
    but my problem is that if I'm doing it from ejb side...i.e. setting "fk_constraint" to false, and setting cascade-delete in ejb-jar.xml (& not in database), then its working fine....
    but if I remove these tags from the ejb-jar and in the database, specify foreign key and ON DELETE CASCADE, then its not working....it is giving the error...
    "can't add or update a child row...foreign key constraint fails".....
    I've read somewhere that this cascade delete option should be specified either on the ejb side or on the db side..and not on both the sides......but in run-time only ejb side is working...
    Plz. help me out coz I want the deletion from db side...as thr are some other tables not used in ejb but dependant on the one used in the ejb side.

    I think that you must specify <cascade-delete/> tag in ejb-jar.xml ONLY. But not in database.

  • Cascading detetion problem

    sir
    i facing problem only in delete case
    i have master detail form i set cascade relation when i delete button code is
    go_block('chartofacc');
         delete_record;
    commit_form;     
    when press exit button system ask me do you want to save change i press yes button but system not delete record and not exit stand last position and show that record
    how i delete my master record with child
    please give me idea how
    thanking you
    Aamir
    how i delete the record plseas give me idea

    try a new form with an easy master and detail block. create a default-cascading-delete relation between them and delete a record in the master manually. then save and check if it is deleted.
    if this test is completed make test 2:
    the same like before, but use your code :
    go_block('master');
    delete_record;
    commit;
    if this runs without problems, then you have to check, what the difference is between your testform2 and your originally form.
    Gerd

  • Apex 4.0 Cascading Select List: ajax problem with german umlaute

    Hi everybody,
    Apex 4.0
    Dad PlsqlNLSLanguage: GERMAN_GERMANY.WE8MSWIN1252
    I have problems with german umlaute and ajax cascading select lists (Cascading LOV Parent Item).
    The data is populated without a page refresh in the select list when the parent select list changes but special signs like german umlaute are shown as weird characters.
    Seems like there is some charset problem with ajax.
    This is the only part of the application where special signs like umlaute are messed up. Everything else is fine.
    I allready tried to figure out if I can escape the umlaute in the javascript (file apex_widget_4_0.js) but no success here.
    Can anybody help me with this issue?
    Thanks in advance,
    Markus

    Hi Markus,
    your specified character set in your DAD is wrong. As mentioned in the installation instructions at http://download.oracle.com/docs/cd/E17556_01/doc/install.40/e15513/otn_install.htm#CHDHCBGI , Oracle APEX always requires AL32UTF8.
    >
    3. Locate the line containing PlsqlNLSLanguage.
    The PlsqlNLSLanguage setting determines the language setting of the DAD. The character set portion of the PlsqlNLSLanguage value must be set to AL32UTF8,
    regardless of whether or not the database character set is AL32UTF8. For example:Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Persist problem in cascade using @OneToMany

    We are trying to persist an object which has a OneToMany relationship to other objects with CascadeType.ALL
    When we persist, the log shows that it creates the INSERT statement with the correct bind variables (sequence-generated REPORT_ID, etc.) for the first object.
    The problem happens when it tries to cascade and insert the Many part. The log shows the it tries to create the INSERT statement for the second object but the bind variable for the REPORT_ID is null.
    Since we defined the relationship of the OneToMany using the REPORT_ID, we assumed that the REPORT_ID that was auto-generated for the first object would be used for the @Many objects.
    What are we missing ??????
    First Object:
    @Id
    @SequenceGenerator(name = "REPORT_HEADER_S", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "REPORT_HEADER_S")
    @Column(name = "REPORT_ID", nullable = false)
    private Long reportId;
    @OneToMany(mappedBy = "report", cascade = { CascadeType.ALL})
    private List<Summary> summaryList;
    Second Object
    @ManyToOne
    @JoinColumn(name = "REPORT_ID", referencedColumnName = "REPORT_ID")
    private Report report;

    Hello, Chris.
    Thank you for your reply.
    The structure of my tables is:
    table document (id int not null constraint document_pk primary key,
    table document_price (document_id int not null constraint document_price_fk references document (id),
    date date not null default current_date,
    price decimal(9,2) not null,
    primary key (document_id, date)).
    The entity classes are:
    @Entity @Table(name = "DOCUMENT")
    public class Document implements Serializable {
    @TableGenerator(name = "document_generator", table = "ID_GENERATION", pkColumnName = "TABLE_NAME", valueColumnName = "ID_VALUE",
    pkColumnValue = "DOCUMENT", allocationSize = 1)
    @Id
    @GeneratedValue(generator = "document_generator")
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    // other fields
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "document", fetch = FetchType.LAZY)
    private Collection<DocumentPrice> documentPriceCollection;
    // constructors, getters, setters ...
    @PostPersist
    public void initializePrices() {
    for (DocumentPrice dp : documentPriceCollection) {
    dp.documentPricePK.setDocumentId(id);
    @Entity
    @Table(name = "DOCUMENT_PRICE")
    public class DocumentPrice implements Serializable {
    @EmbeddedId
    protected DocumentPricePK documentPricePK;
    @Basic(optional = false)
    @Column(name = "PRICE")
    private BigDecimal price;
    @JoinColumn(name = "DOCUMENT_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Document document;
    // constructors, getters, setters ...
    @Embeddable
    public class DocumentPricePK implements Serializable {
    @Basic(optional = false)
    @Column(name = "DOCUMENT_ID")
    private int documentId;
    @Basic(optional = false)
    @Column(name = "DATE")
    @Temporal(TemporalType.DATE)
    private Date date;
    // constructors, getters, setters ...
    I create first Document entity, create DocumentPrice entity and add DocumentPrice entity to the documentPriceCollection of the first Document entity. I invoke commit method of my entity manager, and corresponding rows are added to the document and document_price tables.
    I invoke clear method of my entity manager.
    Then I create new entities Document and DocumentPrice and add new DocumentPrice entity to the documentPriceCollection of the new Document entity. I invoke commit method and get the following exception:
    oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Cannot persist detached object [entities.DocumentPrice[documentPricePK=.entities.DocumentPricePK[documentId=0;
    date=Sat May 29 00:00:00 MSD 2010];
    price=11]].
    Class> entities.DocumentPrice Primary Key> [2010-05-29, 0]
    at oracle.toplink.essentials.exceptions.ValidationException.cannotPersistExistingObject(ValidationException.java:2171)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:3251)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:339)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3220)
    at oracle.toplink.essentials.mappings.CollectionMapping.cascadeRegisterNewIfRequired(CollectionMapping.java:265)
    at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3226)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:205)
    And I see through debugging that @PostPersist method of the Document entity isn't invoked during second commit before the exception is generated.
    What should I do to avoid exception during second commit?

  • Delete Cascade and Composition problem.

    As it's well known into a DB You can have more than one Fk and more than one FK could have Delete cascade set.
    A typical situation is an intersection table between 2 tables wich solves a N to M relationship.
    In BC4J is impossible to manage that situation because Delete Cascate is related to composition and composition tries to lock the owning entity (JBO-25030) however if we try to get the detail row from a ViewLink the other one is invalid and viceversa.
    How can I solve that issue ?
    I read the Steve's http://radio.weblogs.com/0118231/stories/2003/01/17/whyDoIGetTheInvalidownerexception but we normaly don't know, at the create monent all values (the user should select them) and then the createAndInitRow is not a good solution.
    Could someone help.
    TIA
    Tullio

    I've the same Problem and solved it the following way:
    Assuming you have the following VOs:
    MasterView1
    MasterView2
    IntersectionView
    and two Associations of the composition type (each with the Cascading Delete Option between them):
    Ma1InterAssoc
    Ma2InterAssoc
    If you first select a row in MasterView1 and in MasterView2 you can create a new Row in IntersectionView as both "owning Entities" now have a valid current row. BC4J automatically creates the keys to the two Master Entities for you in the Intersection Entity.
    MasterView1Impl vo1 = getMasterView1();
    vo1.selectMyRow(...);
    vo1.executeQuery();
    vo1.next();
    MasterView2Impl vo2 = getMasterView2();
    vo2.selectMyRow(...);
    vo2.executeQuery();
    vo2.next();
    IntersectionView detVo = getIntersectionView);
    Row detRow = detVo.createRow()
    detRow.setValueX(...); // it is important to set at least one value!!
    detVo.insertRow(detRow);
    This method works well since JDeveloper 9.0.3, but unfortunately it is not officially supported by Oracle, so you do it on your own risk :(
    Hope it helps
    Frank

  • JSP + Cascading Style Sheet + Javascript problem

    Hello, I've got a JSP page that has included a Javascript (JS).
    In that JS, a Cascading Style Sheet (CSS) is included. Also on the JSP page, I have some code that makes use of the JS to create a Windows-style combobox, which is not available through raw HTML. The code is as follows:
    <BODY>
    <SCRIPT language="javascript" src="ComboBox.js"></SCRIPT>
    <SCRIPT language="javascript">
    dm=new ComboBox("dm")
    dm.add(
           new ComboBoxItem("barge",1),
           new ComboBoxItem("benluc",2),
           new ComboBoxItem("benlieeeeck",3),
           new ComboBoxItem("taco",4)
    </SCRIPT>
    <CENTER><H2>Choose Project Number</H2><CENTER>
    <FORM METHOD=POST ACTION="">
    <% //DB connection to populate the combo box %>
    <% // Database Connection Parameters
        String DB = "dbname",
        query = "",
        HOST = "jdbc:postgresql://URL:5432/",
        ACCOUNT = "username",
        PASSWORD = "password",
        DRIVER = "org.postgresql.Driver";
        // authentication properties
        Properties props = new Properties();
        props.setProperty("user", ACCOUNT);
        props.setProperty("password", PASSWORD);
        // load driver and prepare to access
        Class.forName(DRIVER).newInstance();
        Connection con = DriverManager.getConnection(HOST + DB, props);
        Statement stmt = con.createStatement();
        try{
        query= "SELECT * FROM Projects ORDER BY Name";
        ResultSet rs = stmt.executeQuery(query);
    %>
    Project S/O:
    <SELECT NAME=projid>
    <option value="dummy">Choose one...</option>
    <% while (rs.next() ) { %>
    <OPTION VALUE="<%=rs.getString("Name") %>">
    <%=rs.getString("Name")%> ,   <%=rs.getString("Desc")%>
    </OPTION>
    <% } %>
    </SELECT>The problem I am experiencing is that if I move the 2nd SCRIPT tag anywhere but where it is, it makes IE bomb and takes me to an error page. The error message is as follows:
    "Internet Explorer cannot open site http://myURL. Operation aborted."
    Any ideas?
    Haig

    I need help in this matter. Someone please reply. Thanks.

Maybe you are looking for

  • Error while starting Managed server in wls

    I am using WebLogic Server Version: 10.3.4.0. I have created one managed server thru admin console. I am starting managed server using startManagedWebLogic.cmd batch file. Chnages I made in this cmd file is added managed server name and wls userid/pa

  • Can I use my Upgrade in the Apple store instead?

    Wanted to know if I'm allowed to use my upgrade at the apple store since i was able to reserve one there?

  • Problems printing - Epson Photo 2200

    I'm having problems printing to my Epson photo 2200. I'm running Mac OS X version 10.4.11. I notice that in the print window there are no longer options for color management, as in to turn it off. The problem I am having is when printing the images c

  • AVCHD and iMovie 08

    Ok, I tried to do a search as to not clutter the discussion forums any more than they are. I am considering purchasing the new Canon HG10. It uses AVCHD. Now I know that there is a lot of dicussion on this. So .. here is my question. I understand the

  • Looking for a good popup extension/plugin

    I have a client with a very specific popup in mind. I've checked around and so far I've been unable to find a program that can do exactly what they're looking for. Something tells me I can do everything listed below right in Dreamweaver but I'm not s