I have this classes
interface UserInterface
Then
abstract class user implements UserInterface
Then i have two child classes
Class Teacher extends User
Class Parent extends User
Now in the dtabase i have three tables
user table with id,passwordteacher with FK and other stuffparent with FK and other stuff
Now i am checking the login using User class.
My problem is that if Employee logins then the object in memory will be of User type. How can then i get the Employee object
Is my model wrong and i need to do different way?
Assuming Employee is a third subclass of User, then if a user logs in, and you get this user from the database using Hibernate, and this user is in fact an employee, then Hibernate will return an Employee instance. It works as you would expect.
If it doesn’t, then you did something wrong, but it’s impossible to tell without seeing the code.