Search Results

Search found 2412 results on 97 pages for 'relationship'.

Page 44/97 | < Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >

  • Hibernate annotated many-to-one not adding child to parent Collection

    - by Rob Hruska
    I have the following annotated Hibernate entity classes: @Entity public class Cat { @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) @Id private Long id; @OneToMany(mappedBy = "cat", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Set<Kitten> kittens = new HashSet<Kitten>(); public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setKittens(Set<Kitten> kittens) { this.kittens = kittens; } public Set<Kitten> getKittens() { return kittens; } } @Entity public class Kitten { @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) @Id private Long id; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Cat cat; public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setCat(Cat cat) { this.cat = cat; } public Cat getCat() { return cat; } } My intention here is a bidirectional one-to-many/many-to-one relationship between Cat and Kitten, with Kitten being the "owning side". What I want to happen is when I create a new Cat, followed by a new Kitten referencing the Cat, the Set of kittens on my Cat should contain the new Kitten. However, this does not happen in the following test: @Test public void testAssociations() { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Transaction tx = session.beginTransaction(); Cat cat = new Cat(); session.save(cat); Kitten kitten = new Kitten(); kitten.setCat(cat); session.save(kitten); tx.commit(); assertNotNull(kitten.getCat()); assertEquals(cat.getId(), kitten.getCat().getId()); assertTrue(cat.getKittens().size() == 1); // <-- ASSERTION FAILS assertEquals(kitten, new ArrayList<Kitten>(cat.getKittens()).get(0)); } Even after re-querying the Cat, the Set is still empty: // added before tx.commit() and assertions cat = (Cat)session.get(Cat.class, cat.getId()); Am I expecting too much from Hibernate here? Or is the burden on me to manage the Collection myself? The (Annotations) documentation doesn't make any indication that I need to create convenience addTo*/removeFrom* methods on my parent object. Can someone please enlighten me on what my expectations should be from Hibernate with this relationship? Or if nothing else, point me to the correct Hibernate documentation that tells me what I should be expecting to happen here. What do I need to do to make the parent Collection automatically contain the child Entity?

    Read the article

  • Database design: OR relation

    - by Ant
    I have a database with a "users" table containing data about my users. Each user is to be linked to a company or a college. I wish to have two separate tables "college" and "company" each with a field "ID". So how do I link each record in the users table to either a company or a college? The basic thing is that I wish to establish an "OR" relationship in the database.

    Read the article

  • Looking for MySQL IDE?

    - by David Negron
    I've recently been tasked with developing a web application that will use a MySQL database on the back end. I for most of my career I have worked with MS-SQL Manager. My greatest weakness is in defining foreign key constraints I usually use MS-SQL Manager's diagramming tool to draw my relationship lines between tables.

    Read the article

  • The multi-part identifier could not be bound

    - by jello
    I have this very simple sql statement: SELECT max_dose FROM psychotropes WHERE (patient_meds.psychotrope = psychotrope_name) AND (patient_meds.patient_id = 12) when I try to run it in Visual Studio 2008, it tells me "The multi-part 'patient_meds.psychotrope' identifier could not be bound" it's weird, because I did set a relationship between the two tables in the diagram viewer

    Read the article

  • Recursive Query Help

    - by Josh
    I have two tables in my database schema that represent an entity having a many-to-many relationship with itself. Role --------------------- +RoleID +Name RoleHasChildRole --------------------- +ParentRoleID +ChildRoleID Essentially, I need to to be able to write a query such that: Given a set of roles, return the unique set of all related roles recursively. This is an MSSQL 2008 Database.

    Read the article

  • DataRelation Insert and ForeignKey

    - by Steve
    Guys, I have a winforms application with two DataGridViews displaying a master-detail relationship from my Person and Address tables. Person table has a PersonID field that is auto-incrementing primary key. Address has a PersonID field that is the FK. I fill my DataTables with DataAdapter and set Person.PersonID column's AutoIncrement=true and AutoIncrementStep=-1. I can insert records in the Person DataTable from the DataGridView. The PersonID column displays unique negative values for PersonID. I update the database by calling DataAdapter.Update(PersonTable) and the negative PersonIDs are converted to positive unique values automatically by SQL Server. Here's the rub. The Address DataGridView show the address table which has a DataRelation to Person by PersonID. Inserted Person records have the temporary negative PersonID. I can now insert records into Address via DataGridView and Address.PersonID is set to the negative value from the DataRelation mapping. I call Adapter.Update(AddressTable) and the negative PersonIDs go into the Address table breaking the relationship. How do you guys handle primary/foreign keys using DataTables and master-detail DataGridViews? Thanks! Steve EDIT: After more googling, I found that SqlDataAdapter.RowUpdated event gives me what I need. I create a new command to query the last id inserted by using @@IDENTITY. It works pretty well. The DataRelation updates the Address.PersonID field for me so it's required to Update the Person table first then update the Address table. All the new records insert properly with correct ids in place! Adapter = new SqlDataAdapter(cmd); Adapter.RowUpdated += (s, e) => { if (e.StatementType != StatementType.Insert) return; //set the id for the inserted record SqlCommand c = e.Command.Connection.CreateCommand(); c.CommandText = "select @@IDENTITY id"; e.Row[0] = Convert.ToInt32( c.ExecuteScalar() ); }; Adapter.Fill(this); SqlCommandBuilder sb = new SqlCommandBuilder(Adapter); sb.GetDeleteCommand(); sb.GetUpdateCommand(); sb.GetInsertCommand(); this.Columns[0].AutoIncrement = true; this.Columns[0].AutoIncrementSeed = -1; this.Columns[0].AutoIncrementStep = -1;

    Read the article

  • A Turing Machine Question

    - by Hellnar
    Greetings, I have been struggling to find a question regarding this theoretical question, even tho it is not directly a programming question, I believe it is really related. Assume a type of Turing machine which cannot have more than 1000 squares. What would be the relationship between the set of such type of recognizable languages and set of normal recognizable languages.

    Read the article

  • Referencing Entity from external data model - Core Data

    - by Ben Reeves
    I have a external library which includes a core data model, I would like to add a new entity to this model which has a relationship with one of the entities from the library. I know I could modify the original, but is there a way to without needing to pollute the library? I tried just creating a new model with an entity named the same, but that doesn't work: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'Host''

    Read the article

  • SQL Server 2005 Users & Roles

    - by koumides
    All, I am trying to script out a database in SQL Server Management Studio 2005. In my database users belong to different roles. Unfortunately I can't find how to script out the relationship between users and roles. Thanks, M

    Read the article

  • App.Config vs. AppName.exe.Config

    - by Randy Minder
    I'm building a Windows Service app that has configuration data stored in App.Config. However, I noticed that when I build my application a AppName.Exe.Config is generated. Can someone tell me the relationship between these two files? Is the AppName.Exe.Config file what I install with my Windows Service app, instead of the app.config? Thanks - Randy

    Read the article

  • Classification of relationships in words?

    - by C.
    Hi, I'm not sure whats the best algorithm to use for the classification of relationships in words. For example in the case of a sentence such as "The yellow sun" there is a relationship between yellow and sun. THe machine learning techniques I have considered so far are Baynesian Statistics, Rough Sets, Fuzzy Logic, Hidden markov model and Artificial Neural Networks. Any suggestions please? thank you :)

    Read the article

  • F# Equivalent to Enumerable.OfType<'a>

    - by Joel Mueller
    ...or, how do I filter a sequence of classes by the interfaces they implement? Let's say I have a sequence of objects that inherit from Foo, a seq<#Foo>. In other words, my sequence will contain one or more of four different subclasses of Foo. Each subclass implements a different independent interface that shares nothing with the interfaces implemented by the other subclasses. Now I need to filter this sequence down to only the items that implement a particular interface. The C# version is simple: void MergeFoosIntoList<T>(IEnumerable<Foo> allFoos, IList<T> dest) where T : class { foreach (var foo in allFoos) { var castFoo = foo as T; if (castFoo != null) { dest.Add(castFoo); } } } I could use LINQ from F#: let mergeFoosIntoList (foos:seq<#Foo>) (dest:IList<'a>) = System.Linq.Enumerable.OfType<'a>(foos) |> Seq.iter dest.Add However, I feel like there should be a more idiomatic way to accomplish it. I thought this would work... let mergeFoosIntoList (foos:seq<#Foo>) (dest:IList<'a>) = foos |> Seq.choose (function | :? 'a as x -> Some(x) | _ -> None) |> Seq.iter dest.Add However, the complier complains about :? 'a - telling me: This runtime coercion or type test from type 'b to 'a involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed. I can't figure out what further type annotations to add. There's no relationship between the interface 'a and #Foo except that one or more subclasses of Foo implement that interface. Also, there's no relationship between the different interfaces that can be passed in as 'a except that they are all implemented by subclasses of Foo. I eagerly anticipate smacking myself in the head as soon as one of you kind people points out the obvious thing I've been missing.

    Read the article

  • Django database caching

    - by hekevintran
    The object user has a foreign key relationship to address. Is there a difference between samples 1 and 2? Does sample 1 run the query multiple times? Or is the address object cached? # Sample 1 country = user.address.country city = user.address.city state = user.address.state # Sample 2 address = user.address country = address.country city = address.city state = address.state

    Read the article

  • Getting started with silverlight 4

    - by nathan gonzalez
    i'm interested in picking up silverlight as another tool to use when appropriate, and i'm looking to get some suggestions on the best way to get started. i have visual studio 2010, and can purchase expression blend if necessary (is it out of beta?), though i haven't quite been able to grasp the relationship between them. are there any good books, tutorials, blogs etc that i should use to familiarize myself with silverlight 4?

    Read the article

  • Delphi 2010 and .net

    - by Kico Lobo
    Hi, how is Delphi 2010 relationship with .net? I remember that not long ago you could only generate .net 1.1 code. And now, how is that? How legacy Delphi code (mostly 7) behave when compiled for the .net platform instead of Win32? Is it compatible?

    Read the article

  • Using cascade in NHibernate

    - by Tyler
    I have two classes, call them Monkey and Banana, with a one-to-many bidirectional relationship. Monkey monkey = new Monkey(); Banana banana = new Banana(); monkey.Bananas.Add(banana); banana.Monkey = monkey; hibernateService.Save(banana); When I run that chunk of code, I want both monkey and banana to be persisted. However, it's only persisting both when I explicitly save the monkey and not vice versa. Initially, this made sense since only my Monkey.hbm.xml had a mapping with cascade="all". <set name="Bananas" inverse="true" cascade="all"> <key column="Id"/> <one-to-many class="Banana"/> </set> I figured I just needed to add the following to my Banana.hbm.xml file: <many-to-one name="Monkey" column="Id" cascade="all" /> Unfortunately, this resulted in a Parameter index is out of range error when I tried to run the snippet of code. I investigated this error and found this post, but I still don't see what I'm doing wrong. I have the relationship mapped once on each side as far as I can tell. For full disclosure, here are the two mapping files: Monkey.hbm.xml <class name="Monkey" table="monkies" lazy="true"> <id name="Id"> <generator class="increment" /> </id> <property name="Name" /> <set name="Bananas" inverse="true" cascade="all"> <key column="Id"/> <one-to-many class="Banana"/> </set> </class> Banana.hbm.xml <class name="Banana" table="bananas" lazy="true"> <id name="Id"> <generator class="increment" /> </id> <property name="Name" /> <many-to-one name="Monkey" column="Id" cascade="all" /> </class>

    Read the article

  • Convert this Linq query from query syntax to lambda expression

    - by Jinkinz
    I'm not sure I like linq query syntax...its just not my preference. But I don't know what this query would look like using lambda expressions, can someone help? from securityRoles in user.SecurityRoles from permissions in securityRoles.Permissions where permissions.SecurableEntity.Name == "Unit" && permissions.PermissionType.Name == "Read" orderby permissions.PermissionLevel.Value descending select permissions There is a many-to-many relationship between users and security roles that makes this extra confusing. Thanks! Kelly

    Read the article

  • NHibernate - I have many, but I only want one!

    - by MartinF
    Hello, I have a User which can have many Emails. This is mapped through a List collection (exposed by IEnumerable Emails on the User). For each User one of the Emails will be the Primary one ("Boolean IsPrimary" property on Email). How can I get the primary Email from User without NHibernate loads every email for the User ? I have the following two entities, with a corresponding table for each public class User { public virtual int Id { get; set; } public virtual IEnumerable<Email> Emails { get; set; } // public virtual Email PrimaryEmail { get; set; } - Possible somehow ? } public class Email { public virtual int Id { get; set; } public virtual String Address { get; set; } public virtual Boolean IsPrimary { get; set; } public virtual User User { get; set; } } Can I map a "Email PrimaryEmail" property etc. on the User to the Email which have "IsPrimary=1" set somehow ? Maybe using a Sql Formula ? a View ? a One-To-One relationship ? or another way ? It should be possible to change the primary email to be one of the other emails, so i would like to keep them all in 1 table and just change the IsPrimary property. Using a Sql Formula, is it be possible to keep the "PrimaryEmail" property on the User up-to-date, if I set the IsPrimary property on the current primary email to false, and then afterwards set the PrimaryEmail property to the email which should be the new primary email and set IsPrimary to true ? Will NHibernate track changes on the "old/current" primary Email loaded by the Sql Formula ? What about the 1 level cache and the 2 level cache when using SqlFormula ? I dont know if it could work by using a View ? Then i guess the Email could be mapped like a Component ? Will it work when updating the Email data when loaded from the View ? Is there a better way ? As I have a bi-directional relationship between User and Email I could in many cases of course query the primary Email and then use the "User" property on the Email to get the User (instead of the other way around - going from User to the primary Email) Hope someone can help ?

    Read the article

  • ASP.NET The underlying connection was closed: Could not establish trust relat

    - by David Lively
    When attempting to use HttpWebRequest to retrieve a page from my dev server, I get a web exception: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." The remote certificate is invalid according to the validation procedure... The url I'm attempting to read from is a plain-old http://myserver.com/mypage.asp - no SSL. The production server has a valid certificate so this shouldn't be an issue, but our dev server doesn't. Help!

    Read the article

  • IoC, AOP and more

    - by JMSA
    What is an IoC container? What is an IoC/DI framework? Why do we need a framework for IoC/DI? Is there any relationship between IoC/DI and AOP? What is Spring.net/ninject with respect to IoC and AOP?

    Read the article

< Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >