jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Neo
  • NEO-41

Foreign key not settled associating new objects

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.3.2
  • Fix Version/s: 1.5.0
  • Component/s: Core
  • Labels:
    None
  • Environment:
    Neo 1.3.2, default build. Running on WinXP Pro against SQLServer 2000.
  • Testcase included:
    yes

Description

Hi,

Note: You can find the full project attached, I only post excerpts here.

I have two relations (foreign keys) in my Branch class:

<column name="CustomerId" required="true" hidden="true" type="INTEGER" />
<column name="LocationId" required="true" hidden="true" type="INTEGER" />

<!-- Backreference to Customer -->
<foreign-key foreignTable="Customers" name="Customer" onDelete="none">
<reference local="CustomerId" foreign="Id"/>
</foreign-key>

<!-- Reference to the branch location -->
<foreign-key foreignTable="Locations" name="Location" onDelete="none">
<reference local="LocationId" foreign="Id"/>
</foreign-key>

In the Customer class I defined an iforeign-key because I need the Branches collection in this class, but I didn't need a Branches collection y my Location class.

If I run the following test:

aCustomer = new CustomerFactory( context ).CreateObject();
aCustomer.Code = "99999";
aCustomer.Name = "Carlos Peix";

aLocation = new LocationFactory( context ).CreateObject();
aLocation.Code = "HERE";

aBranch = new BranchFactory( context ).CreateObject();
aBranch.Code = "99999";
aBranch.Name = "Praxia";
aBranch.Location = aLocation;

aCustomer.AddBranch( aBranch );

context.SaveChanges();

I get a SQLServer foreign key violation caused by the following statement:

08:42:52,842: INSERT INTO Branches (Code, Name, CustomerId, LocationId) VALUES (@Code, @Name, @CustomerId, @LocationId)
08:42:52,842: @Code = 99999
08:42:52,842: @Name = Praxia
08:42:52,842: @CustomerId = 3
08:42:52,842: @LocationId = -1

As you can see, the LocationId field contains his default value.

If I uncomment de iforeign-key relation in the Locations class which defines the Branches collection I obtain a green bar.

I suppose that this is a bug, right now I can workaround this defining this iforeing-key.

Thanks

Carlos

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    Tests.zip
    22/Sep/05 7:16 AM
    18 kB
    Carlos Peix
    1. Text File
      LOG with-iref.txt 4 kB
    2. File
      Tests.sln 0.9 kB
    3. File
      build/makeschema.bat 0.2 kB
    4. File
      build/NeoClass.vtl 0.8 kB
    5. File
      build/NeoCreateDb.vtl 1 kB
    6. File
      build/NeoSupport.vtl 16 kB
    7. File
      Contexts/AssemblyInfo.cs 2 kB
    8. File
      Contexts/Contexts.csproj 6 kB
    9. File
      Contexts/Model/Branch.cs 0.6 kB
    10. File
      Contexts/Model/Contexts-schema.cs 29 kB
    11. XML File
      Contexts/Model/Contexts-schema.xml 2 kB
    12. File
      Contexts/Model/Customer.cs 1.0 kB
    13. File
      Contexts/Model/Location.cs 0.6 kB
    14. File
      Contexts/Model/norque.dtd 4 kB
    15. File
      Contexts/Test/Relations.cs 1 kB
    16. File
      Contexts/Test/TestBase.cs 0.5 kB
    17. File
      log4net.config 0.7 kB
    18. Text File
      LOG no-iref.txt 2 kB
    Download Zip
    Show
    Zip Archive
    Tests.zip
    22/Sep/05 7:16 AM
    18 kB
    Carlos Peix

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Erik Doernenburg added a comment - 22/Sep/05 4:12 PM

Thanks for reporting this. It is a known bug that has been discussed on the mailing list but somehow I forgot to add it to Jira. It would be great if we could fix this but unfortunately I currently don't know how.

Show
Erik Doernenburg added a comment - 22/Sep/05 4:12 PM Thanks for reporting this. It is a known bug that has been discussed on the mailing list but somehow I forgot to add it to Jira. It would be great if we could fix this but unfortunately I currently don't know how.
Hide
Permalink
Carlos Peix added a comment - 23/Sep/05 6:53 AM

Erik,

Sorry for reporting a known issue. I'll investigate posible fixes.

Thanks for your work.

Carlos

Show
Carlos Peix added a comment - 23/Sep/05 6:53 AM Erik, Sorry for reporting a known issue. I'll investigate posible fixes. Thanks for your work. Carlos

People

  • Assignee:
    Erik Doernenburg
    Reporter:
    Carlos Peix
Vote (0)
Watch (1)

Dates

  • Created:
    22/Sep/05 7:16 AM
    Updated:
    24/Apr/06 4:21 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.