hibernate - Hibernate many to many, with extra columns select using extra column in where
问题描述
so I have followed this page and it is now working for findAll https://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/
but what I can find nowhere to tell me is how to use the extra column in the where section of a select, in My DAO.
so taking the stock example in that page I only want to select stock that was stocked in the last week.
findByDate (for example)
here are the tables from the example:
CREATE TABLE `stock` (
`STOCK_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`STOCK_CODE` VARCHAR(10) NOT NULL,
`STOCK_NAME` VARCHAR(20) NOT NULL,
PRIMARY KEY (`STOCK_ID`) USING BTREE,
UNIQUE KEY `UNI_STOCK_NAME` (`STOCK_NAME`),
UNIQUE KEY `UNI_STOCK_ID` (`STOCK_CODE`) USING BTREE
)
CREATE TABLE `category` (
`CATEGORY_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`NAME` VARCHAR(10) NOT NULL,
`DESC` VARCHAR(255) NOT NULL,
PRIMARY KEY (`CATEGORY_ID`) USING BTREE
)
CREATE TABLE `stock_category` (
`STOCK_ID` INT(10) UNSIGNED NOT NULL,
`CATEGORY_ID` INT(10) UNSIGNED NOT NULL,
`CREATED_DATE` DATE NOT NULL,
`CREATED_BY` VARCHAR(10) NOT NULL,
PRIMARY KEY (`STOCK_ID`,`CATEGORY_ID`),
CONSTRAINT `FK_CATEGORY_ID` FOREIGN KEY (`CATEGORY_ID`)
REFERENCES `category` (`CATEGORY_ID`),
CONSTRAINT `FK_STOCK_ID` FOREIGN KEY (`STOCK_ID`)
REFERENCES `stock` (`STOCK_ID`)
)
I have found pages to help me get so far but every tutorial appears to be missing this vital fact. Could somebody help point me further.
if I knew hibernate well the answer may be obvious but I don't
解决方案
推荐阅读
- javascript - 检测反应本机 webview 中的 URL 更改,注入的 javascript 未加载到导航到的页面上
- ios - 安装firebase时如何防止应用程序崩溃
- java - 读取数据然后更新并保存完成
- ios - 为什么 swift 无法在 ForEach 循环中使用 array[index+1] 渲染视图?
- twitter-bootstrap - 如何将 Bootstrap 框架限定为仅在一个 css id 下“应用”?
- c - 与硬编码输入相比,使用 fgets 从用户获取密钥时无法打印密钥流
- r - R 中 SF 库中的 St_perimeter
- javascript - 为什么我的 html 元素值对象不是数组,为什么它们彼此不等价?
- json - 将 GeoJSON 文件导入 React-Leaflet
- android - RecyclerView在搜索后使用onClick获取错误的位置