I have hit a brick wall in my understanding of associations and using them. it may be an over-active brain but there seems so many possibilities. I want 2 instances of a java class/DB table as instance variable of a second class/DB Table. basically I want each Dog instance variable in Race to hold one instance of a Dog, I have tried various combinations of @OneToOne @OneToMany and @ManyToOne but it crashes every time:
I am a novice and tryng to learn from books and the net , but have got to a stage where there are so many examples that I don't know which to choose, I'm out of my depth because I don't know what should happen or even if what I am tryng to do is possible.it seems like it should.
If you think it would be better in the EJB thats fine by me, but please could you explain how I get admin to move it.
The admin has already moved the thread to 'Object Relational Mapping' forum(check out the forum title at the top), so all you need to do now is - TellTheDetails - i.e. what exactly is the problem.
Joined: Apr 30, 2012
What I am trying to do is to use an instance of the dog class/database as an instance variable in the race class.
there will be a lot of dogs in the database, but only one of them will be a winner and one of them in second place in each race. I want to be able to store each of those dogs as an instance variable of type dog in an instance of race.
I get an error of Entity not defined if I leave the variables without anything before them.
I have tried
@OneToOne(mappedBy = "Dog")
@OneToOne(mappedBy = "dogID");
@OneToOne(mappedBy = "Dogs_ID");
@OneToOne(mappedBy = "DOGS");
@OneToMany(mappedBy = "Dog")
@OneToMany(mappedBy = "Dog_ID")
@OneToMany(mappedBy = "DOGS")
@OneToMany(mappedBy = "dogID")
@ManyToOne mappedBy wouldn't work on that
I have tried
@JoinColumn( name = "dogID")
@JoinColumn( name = "dog_dogID")
@JoinColumn( name = "DOGS_ID")
@JoinColumn( name = "DOGS_dogID")
but the log says it cannot find "columnname"
I can't figure out what the relationship should be.
I want one dog from many but not one specific dog record which can be pointed to in advance,
I don't want many dogs as there will only be one for each variable,
there will be one race to many dogs but I only want one of the dogs for each instance.
There will be some dogs for each race but many dogs for all of the races, I want one dog from the some dogs.
Brain in overdrive and going nowhere. help.
I can't produce the rest of the code until I have somewhere to store the winner and runner-up.
subject: creating an instance variable of a database table type for persistance