リレーションテーブルの株式カテゴリに行を挿入しようとしています。
私はこの例に従っています:http ://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/
これで、テーブル在庫とカテゴリのデータがすでにあります。
後で、株式とカテゴリを相互に関連付けたいと思います。
カスタムSQLクエリを記述せずにこれを行うにはどうすればよいですか?
このようにStockCategoryを追加できれば可能ですか?
Stock stock = new Stock();
stock.setStockId(1);
Category category = new Category();
category.setCategoryId(1);
StockCategory stockCategory = new StockCategory();
stockCategory.setStock(stock); //here you need to get the stock object by id
stockCategory.setCategory(category1); //here you need to get the category1 object by id
stockCategory.setCreatedDate(new Date()); //extra column
stockCategory.setCreatedBy("system"); //extra column
session.save(stockCategory );
前もって感謝します。