Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Databases
»
Object Relational Mapping
Table per class heirarchy
Joe San
,
Ranch Hand
Feb 07, 2008 00:28:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Guys,
Why is that the subclass elements cant have NOT NULL set for their attributes? I'm failing to understand this!
Danilo Dadonas
,
Ranch Hand
Feb 17, 2008 13:49:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Hi, Jothi. Supose that we have the following classes:
-----------
Person
-----------
name
homeAddress
-----------
----------
Teacher extends Person
----------
university
salary
----------
----------
Student extends Person
----------
ipod
----------
the table than is:
--------------
Person
--------------
name
home_address
university
salary
ipod
--------------
Considerete the
Java
code:
Person person;
person = new Teacher("Dadonas","76th Street, 1234", "Harvard", "10,000");
HibernateUtil.getSession().saveOrUpdadte(person);
If the field ipod of the table was marked with not null, a null exception would be throwed.
If we do this:
person = new Student("Dadonas","76th Street, 1234", "MyiPod");
HibernateUtil.getSession().saveOrUpdadte(person);
If the fields university and salary was marked with not null, a null exception would be throwed.
The fields in this case can't be not null.
I hope it helps you.
Joe San
,
Ranch Hand
Feb 18, 2008 06:20:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Thanks man!
Post by:
autobot
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 640 times.
Similar Threads
Using discriminator on base class with no subclasses
Misleading Inheritance Model names - Java Beat questions
Help with a Mapping
casting
Hibernate @DiscriminatorColumn
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:35:53
.