Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] pojo mapping

Can some one give me so help with this, I have 2 classes pojos mapped to 2 tables using the workbench, item and menu. Item uses a default sequencing and menus Id prim key needs to be the same values as items. I know it can be done but can not getting it working.

If some one could help that would be great.


in its simplest for they are like this

Tables
DROP TABLE IF EXISTS `test`.`item`;
CREATE TABLE  `test`.`item` (
 `ID` int(11) NOT NULL auto_increment,
 `TEXT` varchar(20) default NULL,
 PRIMARY KEY  (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `test`.`menu`;
CREATE TABLE  `test`.`menu` (
 `ID` int(11) NOT NULL,
 `TEXT` varchar(20) default NULL,
 PRIMARY KEY  (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

both just a ID and text.
the class are

import org.eclipse.persistence.indirection.ValueHolder;
import org.eclipse.persistence.indirection.ValueHolderInterface;

public class Item {

   public Item() {
       // TODO Auto-generated constructor stub
   }
   private ValueHolderInterface menu = new ValueHolder();
   public Menu getMenu() {
       return (Menu)menu.getValue();
   }
   public void setMenu(Menu menu) {
       this.menu.setValue(menu);
   }
   public int getId() {
       return id;
   }
   public void setId(int id) {
       this.id = id;
   }
   public String getText() {
       return text;
   }
   public void setText(String text) {
       this.text = text;
   }
   private int id;
   private String text="";

}

import org.eclipse.persistence.indirection.ValueHolder;
import org.eclipse.persistence.indirection.ValueHolderInterface;

public class Menu {

   public Menu() {
       // TODO Auto-generated constructor stub
   }

   public Menu(Item item) {
       this.setOwner(item);
       // TODO Auto-generated constructor stub
   }

   private ValueHolderInterface owner = new ValueHolder();
   private int id;
   private String text = "";

   public Item getOwner() {
       return (Item) owner.getValue();
   }

   public void setOwner(Item owner) {

       this.owner.setValue(owner);
   }

   public int getId() {
       return id;
   }

   public void setId(int id) {
       this.id = id;
   }

   public String getText() {
       return text;
   }

   public void setText(String text) {
       this.text = text;
   }

}



Back to the top