Hibernate中的小写注释(Lowercase annotation in Hibernate)
在hibernate中是否有任何方法可以将实体的列注释为字符串小写? 我的意思是例如
@Entity public class User { @Column private String username; }
我希望hibernate在没有绑定到特定数据库的所有查询中将用户名转换为小写。
Is there any way in hibernate to annotate the column of the entity to string lowercase? I mean for example
@Entity public class User { @Column private String username; }
I want the hibernate to convert the username to lowercase in all queries not tied to a specific database.
原文:https://stackoverflow.com/questions/13108559
最满意答案
“我不认为这个问题要求薪水在失败和医疗之间。”
这个问题表明工资需要匹配一个特定的
grade
。“C的工资等级
当然,经典SCOTT / TIGER模式中的SALGRADE具有数字
grade
:SQL> select * from salgrade; GRADE LOSAL HISAL ---------- ---------- ---------- 1 700 1200 2 1201 1400 3 1401 2000 4 2001 3000 5 3001 9999 SQL>
问题的不确定性与答案的奇异本质相吻合。 无论如何,正如我们所看到的,等级被分配到薪水带。 因此,为了找到特定年级的员工,我们需要将他们的薪水与该等级的上限和下限相匹配,
losal
和hisal
。这是一个解决方案:
SQL> select empno, ename, job, mgr 2 from emp 3 join dept 4 on emp.deptno = dept.deptno 5 join ( select * from salgrade 6 where grade = 3 ) sg3 7 on emp.sal between sg3.losal and sg3.hisal 8 where dept.dname IN ('SALES', 'RESEARCH') 9 / EMPNO ENAME JOB MGR ---------- ---------- --------- ---------- 7499 ALLEN SALESMAN 7698 7844 TURNER SALESMAN 7698 SQL>
我更愿意保持连接条件与过滤器分开。 有几种方法可以做到这一点,查询演示了两种方法:
- 在内联视图中过滤表格
- 在主查询的WHERE子句中过滤表
语法允许我们在
on
子句中包含非连接条件,但这可能会产生副作用。 最好在连接和过滤器之间进行清晰的分离,这是ANSI 92语法的要点。" I don't think the question asked for salary to be between losal and hisal."
The question states the salary needs to match a specific
grade
." a salary grade of C.
Of course SALGRADE in the classic SCOTT/TIGER schema has a numeric
grade
:SQL> select * from salgrade; GRADE LOSAL HISAL ---------- ---------- ---------- 1 700 1200 2 1201 1400 3 1401 2000 4 2001 3000 5 3001 9999 SQL>
The sloppiness of the question fits the bizarre nature of the answer. Anyway, as we can see, the grades are allocated to salary bands. So to find the employees in a particular grade we need to match their salary to the upper and lower bounds of that grade,
losal
andhisal
.Here is one solution:
SQL> select empno, ename, job, mgr 2 from emp 3 join dept 4 on emp.deptno = dept.deptno 5 join ( select * from salgrade 6 where grade = 3 ) sg3 7 on emp.sal between sg3.losal and sg3.hisal 8 where dept.dname IN ('SALES', 'RESEARCH') 9 / EMPNO ENAME JOB MGR ---------- ---------- --------- ---------- 7499 ALLEN SALESMAN 7698 7844 TURNER SALESMAN 7698 SQL>
I prefer to keep join conditions separate from filters. There are a couple of ways of doing this, and the query demonstrates both:
- Filter the table in an inline view
- Filter the table in the main query's WHERE clause
The syntax allows us to include non-joining conditions in the
on
clause, but this can have side-effects. It's better to be clarity between joins and filters, which separation is the main point of the ANSI 92 syntax.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
阅读这篇关于“代码项目”的原始文章可以帮助您: SQL连接的视觉表示 。 还要检查这篇文章: SQL SERVER - 更好的性能 - LEFT JOIN还是不在? 。 查找原文: MySQL中的JOIN和OUTER JOIN之间的区别 。 Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins. Also check this post: SQL SE ...
-
通常它们是相同的,但是较低的一个 - 也称为“ANSI连接语法”应该是Oracle推荐的首选,并且由于许多其他原因,请参阅OUTER JOIN文档。 只有一个例外(我知道):当您使用FAST REFRESH创建MATERIALIZED VIEW ,您必须使用旧的Oracle连接语法,否则无法进行FAST REFRESH。 很久以前我在Oracle创建了一个SR。 Oracle并不认为这是一个错误,而是“缺乏文档”。 根据我的知识,这个限制/错误仍然没有解决。 In general they are equa ...
-
你只需要exists : update Project p set Name = p.Name+' assignedTo ' where exists (select 1 from EmployeeProject join Employee e on ep.EmployeeID = e.ID where e.Name = N'Minion' and p.ID = ep ...
-
答案总是0(Answer is always 0)[2022-09-17]
您的accept方法为p , n和r声明了新的局部变量 - 它没有为实例变量赋值,它仍然具有值0.而不是声明局部变量,您应该只为实例变量赋值。 例如,这一行: int p = Integer.parseInt(br.readLine()); 应该: p = Integer.parseInt(br.readLine()); 此外,正如其他人所指出的那样,算术完全在整数数学中执行。 如果你真的想要一个整数结果并不重要(例如,如果你不介意在p , n和r都是10的情况下得到0) - 但如果你想得到非整数结果, ... -
尝试: select ..... from
where id in ( ) for UPDATE; 编辑 :这可能看起来有点违反直觉,考虑到你所关联的问题(它询问如何免除IN ),但如果你的联接返回限制集,可能仍然会提供好处。 但是,没有解决方法:oracle异常非常明显; 由于DISTINCT ,oracle不知道要锁定哪些行。 您可以省略DISTINCT或在视图中定义所有内容,然后在没有显式锁定的情况下更新它: htt ... -
Oracle有没有其他方法可以像使用JOIN一样获得答案?(Oracle Is there another way to get the answer like using a JOIN?)[2022-12-31]
“我不认为这个问题要求薪水在失败和医疗之间。” 这个问题表明工资需要匹配一个特定的grade 。 “C的工资等级 当然,经典SCOTT / TIGER模式中的SALGRADE具有数字grade : SQL> select * from salgrade; GRADE LOSAL HISAL ---------- ---------- ---------- 1 700 1200 2 1201 ... -
连接的列就在加号之前。 ... FROM CustomerShip s LEFT OUTER JOIN (....) i ON s.ShipSeq = i.ShipSeq The columns that are joined on are just before the plus sign. ... FROM CustomerShip s LEFT OUTER JOIN (....) i ON s.ShipSeq = i.ShipSeq
-
内连接(Oracle)(inner join as on (Oracle))[2023-04-30]
对于表的别名,Oracle不接受关键字 Oracle doesn't accept the keyword as for table's aliases