title: Hibernate many to many, with extra columns select using extra column in where
body: <p>so I have followed this page and it is now working for findAll
  <a href="https://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/" rel="nofollow noreferrer">https://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/</a></p>
  
  <p>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.</p>
  
  <p>so taking the stock example in that page I only want to select stock that was stocked in the last week.</p>
  
  <p>findByDate (for example)</p>
  
  <p>here are the tables from the example:</p>
  
  <pre><code>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`)
  )
  </code></pre>
  
  <p>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.</p>
  
  <p>if I knew hibernate well the answer may be obvious but I don't</p>