English 中文(简体)
从数据库中除去有藏书的重复浏览量
原标题:remove duplicate rows from database with hibernate

我有一只手文件,内容如下:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping auto-import="true" default-lazy="false">
    <class name="com.saman.entity.hibernate.EmployeeEntity"
           table="Employee" optimistic-lock="version">
        <id name="id">
            <column name="Id" sql-type="bigint"/>
            <generator class="native"/>
        </id>
        <timestamp name="version" source="db"/>
        <property  name="firstName">
            <column name="FirstName" sql-type="nvarchar(300)"/>
        </property>
        <property name="lastName">
            <column name="LastName" sql-type="nvarchar(300)"/>
        </property>
        <property name="employeeType">
            <column name="EmployeeType" sql-type="nvarchar(300)"/>
        </property>
        <set name="shifts" table="Shifts" inverse="true" lazy="true" fetch="select">
            <key>
                <column name="Id" not-null="true"/>
            </key>
            <one-to-many class="com.saman.entity.hibernate.ShiftEntity"/>
        </set>
    </class>
</hibernate-mapping>

现在我想要的是,如果我增加一名雇员并坚持该雇员,那么如果我用以前的资料补充另一名雇员的话,我的制度就会产生一个例外,告诉我,我还有另一名雇员在数据库中掌握这些信息。

难道我可以放心吗?

最佳回答

完全有理由在你绘制地图时添加这一点。

<properties name="firstName_lastName_unique" unique="true">
        <property name="firstName"/>
        <property name="lastName"/>
</properties>
问题回答

我认为,我理解你想要实现的目标。 但是,我不知道你是否首先在 st流中找过问题。 您的答复如下:。 如何用多个一栏进行单独限制?

您在数据库中是否对ID栏进行自动加插?

你们已经为补贴价值创造了一个发电机。 这应当产生一种独一无二的补贴,但只有符合以下两项条件:

  1. The column either is defined as autoincrement (p. ex. MySQL) or has a sequence (p. ex. Oracle)
  2. When saving a new row, the member variable id is set to 0.

我可以想象,当你用以前的资料节省新的价值时,变数的折合点仍然具有价值! = 0,在这种情况下,数据库使用特定价值,而不是产生新的独一无二的价值,而由于独特的限制,这种价值将失败。

如果表上有第二个独一无二的指数,这一错误也会出现。





相关问题
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 ...

热门标签