private Order order;
Defining like this is correct one... Since all are done in Object Oriented manner... Invoice "has"(possess) Order object... JPA Entity Manager will deal the foreign key mapping between Invoice and Order with the help of annotation "JoinColumn"... Thats the purpose JoinColumn annotation serves here...
Defining directly the "Order_id" int type means manually we have to give the Order id by not utilizing the Entity Manager Auto-Mapping feature...
When persisting the new Invoice object, the new Invoice object should have "Order" object set in the new Invoice object..
While making an insertion of new Invoice object as relational record in relational database, implicitly Entity Manager search for "Order_Id" DB field name (Order Table Primary Key field) mapped instance variable in Order object and maps to foreign key column "Order_Id" of Invoice table...
like..
insert into Invoice(col1,col2,Order_Id) values(val_col1,val_col2,<Order_Id_value extracted from Order object which was possessed by Invoice Object>)