English 中文(简体)
数据库与日本邮政局的独立直线比较
原标题:Database independent string comparison with JPA

I m与JPA(自愿作为供应商)和MySQL数据库合作。

我的桌子包含德国的街道名称。 每个街道名称都有独特的号码。 就一项任务而言,我必须找到名字。 为了做到这一点,我写了一封信件,如:

"SELECT s FROM Strassencode s WHERE s.name = :name"

不幸的是,德国的街道名称在“Am kleinen Feld”和“Am Kleinen Feld”等小型和资本信件中仅有所不同。 很明显,其中之一是错误的,但作为街道的名称,两种拼法都是允许的,两者都有不同的数字。

When I send my JPQL-Query to the database, I m using

query.getSingleResult();

事实上,表中每个街道名称都是独特的。 但是,根据MySQL-Database,我收到一份“NonUniqueResultException

SELECT  abc  LIKE BINARY  ABC ;

as discribed in chapter 11.5.1 in the mySQL Reference Manual, but there is no corresponding keyword in JPQL.

我的第一项尝试是,在标有<<> 姓名>的类别中指明外地。

@Column(nullable = false, columnDefinition = "varbinary(128)")

与此类似,该数据库自动进行案件敏感比较,因为其中一项指示是双向的。 但是,当我使用这一解决办法时,我会遇到麻烦,在我宣读数据带的名字时,会把他们写进档案中,因为当时像奥地利、哥、居等信件被错误地解释。

我知道,现场<代码>名称。 一、背景 制约和制约是我的目标之一,但只有在数据库进行案件敏感细微比较的情况下,才有可能这样做。

Is there a solution, where I can configure JPA to do case sensitive string comparison without having to manually fine-tune the database?

最佳回答
问题回答

如你对数据库和JPA供应商说的那样,保留“独立”的做法,即避免“独立”和“独立”清单,并保持名称的记忆。 可以证明,你会得到不止一个但不超过100个。

另一种办法是,在新的领域节省正常的名称(豁免,减少案件)。

页: 1 这是一种正常的争辩:

Query sqlQuery = session.createSqlQuery("select * from CITY where name like binary :name ).addString( name , name);

请注意,该守则大致照此办理。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签