• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is wrong with this Hibernate annotation?

 
William Fernandes
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys!

I'm beginning with Hibernate and I read a tutorial, telling how to do one-to-many relation using annotations. Exactly what I wanted to know.

It's very simple: one course has many students.





It actually saves in the database, but in the Student table the code (of the course, FK) is NULL.
The tables were created based on these annotations, it's really the same thing.

As I copied a lot of things from the tutorial (it was very alike) there are some annotations I don't know what they mean, like @JoinColumn, @Fetch and @Cascade. Are they really necessary? I'd like to keep it as simple as possible.

Thanks anyway.

[ August 31, 2008: Message edited by: William Fernandes ]
[ August 31, 2008: Message edited by: William Fernandes ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are generating the tables from source/annotations, and you are using Generics, you can get away with just

@OneToMany and

@ManyToOne only with cascade types though. I recommend the following. Try that out.



Mark
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic