I have stored objects in a database using tables, I retrieve data from objects in following way:
String query = "SELECT * FROM Librarian WHERE (id = ?)";
Account ac = null;
try {
state = conn.prepareStatement(query);
state.setString(1,passport);
rs = state.executeQuery();
if(rs.next()) {
ByteArrayInputStream bais = new ByteArrayInputStream(rs.getBytes("Object"));
try {
ObjectInputStream ois = new ObjectInputStream(bais);
ac = (Account) ois.readObject();
and then I can access values e.g ac.getName etc.. But this gives me only one object. In a table(given below) I have stored 3 foreign keys and I want to join 3 tables to get information from them, but each table has Object i.e I want to retrieve information from those Objects, hence I want to join tables and get information from objects.
CREATE TABLE Orders
(OrderID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Passport VARCHAR(20) NOT NULL,
FOREIGN KEY (Passport) REFERENCES Guest(Passport) ON DELETE CASCADE,
ISBN INT NOT NULL,
FOREIGN KEY (ISBN) REFERENCES Books(ISBN) ON DELETE CASCADE,
LibPassport VARCHAR(20) NOT NULL,
FOREIGN KEY (LibPassport) REFERENCES Account(LibPassport) ON DELETE CASCADE,
Object LONGBLOB NOT NULL
);
If you need more explanations or code please let me know.
Regards,