2 Replies Latest reply on Feb 21, 2007 8:20 AM by micho

    @UniqueConstraint has no Effect in MQSQL

    micho

      Hi,

      I definde an entitybean with a uniqueConstraint like this

      @Table
      (name="usergroup",
       uniqueConstraints = {@UniqueConstraint(columnNames={"mandantID", "name"})}
      )
      public class BenutzerGruppe implements Serializable
      { private long mSid;
       private long mMandantID;
       private String mName;


      I cannot see any effect in the database and it is possible to insert entities which violates the constraint.

      I´m using MySQL 5.0.24a

      Do I have to do anything more than using the annotaion in the entitybeandefinition?

        • 1. Re: @UniqueConstraint has no Effect in MQSQL
          micho

          jboss-4.0.4.GA_1 is used

          • 2. Re: @UniqueConstraint has no Effect in MQSQL
            micho

            is it possible that the schema update doesn´t work correctly?
            I created an new entitybean with uniquconstraint and a unique index was created.

            here is my persistence.xml

            persistence>
             <persistence-unit name="BBCS">
             <jta-data-source>java:/MySqlDS</jta-data-source>
             <properties>
             <property name="hibernate.hbm2ddl.auto"
             value="update "/>
             <!-- value="create-drop"/> -->
             <property name="hibernate.dialect"
             value="org.hibernate.dialect.MySQL5Dialect"></property>
             </properties>
             </persistence-unit>
            </persistence>