0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MyBatisでExampleClassをカスタマイズする

Last updated at Posted at 2023-07-05

自動生成したExampleClassに追加の抽出条件を加える

テーブルを結合して他のテーブルのカラムを抽出条件とすることがある。この場合は、他のテーブルのExampleClassから該当の抽出条件を持ってきて、以下のように追加する。このとき、通常のものとエイリアスを付けるものを両方用意しておくと、複数人で開発するときなどに便利である。


public class MTestExample {
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database table dbo.M_TEST
	 * @mbg.generated
	 */
	protected String orderByClause;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database table dbo.M_TEST
	 * @mbg.generated
	 */
	protected boolean distinct;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database table dbo.M_TEST
	 * @mbg.generated
	 */
	protected List<Criteria> oredCriteria


   // ... 略
		

	/**
	 * This class was generated by MyBatis Generator. This class corresponds to the
	 * database table dbo.M_TEST
	 *
	 * @mbg.generated do_not_delete_during_merge
	 */
	public static class Criteria extends GeneratedCriteria {
		protected Criteria() {
			super();
		}

		// ↓↓↓ ここは上書きされないので、ここから下に追記していく ↓↓↓
        public Criteria andDeleteFlgEqualTo(String value) {
			addCriterion("DELETE_FLG =", value, "deleteFlg");
			return (Criteria) this;
		}

        public Criteria andDeleteFlgEqualTo(String value, String alias) {
			addCriterion(alias + ".DELETE_FLG =", value, "deleteFlg");
			return (Criteria) this;
		}
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?