-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: delete an entry in db, with session bean in jboss
PostPosted: Wed Jun 08, 2005 3:00 am 
Newbie

Joined: Tue May 31, 2005 10:31 am
Posts: 5
Hello,

i am trying to delete a entry in my db.
i am using a session bean in jboss, and this session bean creates and manipulates the entries well, but there's no way to delte it.
the statements used are tested in the SQL Worksheet, and working.
How can i delete these entries.

Thanks

Markus



Hibernate version:
3.0.5
JBoss version:
4.0.2
Name and version of the database you are using:
Oracle9i 9.2.0.4

Mapping documents:
Mapping für AC_USER

Code:
<hibernate-mapping>
  <class name="de.psb_gmbh.main.business.persistence.AcUser" table="AC_USER" schema="LAGERDBA">
    <id name="UserId">
      <column name="USER_ID"/>
      <generator class="assigned" />
    </id>
    <many-to-one name="AcGroup" class="de.psb_gmbh.main.business.persistence.AcGroup">
      <column name="MASTER_GROUP_ID"/>
    </many-to-one>
    <property name="LoginName">
      <column name="LOGIN_NAME"/>
    </property>
    <property name="Name">
      <column name="NAME"/>
    </property>
    <property name="Password">
      <column name="PASSWORD"/>
    </property>
    <property name="CheckCount">
      <column name="CHECK_COUNT"/>
    </property>
[b]    <set name="SetOfAcUserToGroup">
      <key>
        <column name="USER_ID" />
      </key>
      <one-to-many class="de.psb_gmbh.main.business.persistence.AcUserToGroup" />
    </set>[/b]
  </class>
</hibernate-mapping>



Mapping für AC_USER_TO_GROUP
Code:
<hibernate-mapping>
  <class name="de.psb_gmbh.main.business.persistence.AcUserToGroup" table="AC_USER_TO_GROUP" schema="LAGERDBA">
    <composite-id name="id" class="de.psb_gmbh.main.business.persistence.AcUserToGroupId">
      <key-many-to-one name="AcGroup" class="de.psb_gmbh.main.business.persistence.AcGroup">
        <column name="GROUP_ID"/>
      </key-many-to-one>
     [b] <key-many-to-one name="AcUser" class="de.psb_gmbh.main.business.persistence.AcUser">
        <column name="USER_ID"/>
      </key-many-to-one>[/b]
    </composite-id>
    <property name="CheckCount">
      <column name="CHECK_COUNT"/>
    </property>
  </class>
</hibernate-mapping>



AcUser.java
Code:
public class AcUser implements java.io.Serializable {

  // Fields
  private String UserId;
  private AcGroup AcGroup;
  private String LoginName;
  private String Name;
  private String Password;
  private Integer CheckCount;
  private Set<AcUserToGroup> SetOfAcUserToGroup;

  // Constructors
  public AcUser() {
  }

  // Property accessors
 
  public String getUserId() {
    return this.UserId;
  }

  public void setUserId(String UserId) {
    this.UserId = UserId;
  }

  public AcGroup getAcGroup() {
    return this.AcGroup;
  }

  public void setAcGroup(AcGroup AcGroup) {
    this.AcGroup = AcGroup;
  }

  public String getLoginName() {
    return this.LoginName;
  }

  public void setLoginName(String LoginName) {
    this.LoginName = LoginName;
  }

  public String getName() {
    return this.Name;
  }

  public void setName(String Name) {
    this.Name = Name;
  }

  public String getPassword() {
    return this.Password;
  }

  public void setPassword(String Password) {
    this.Password = Password;
  }

  public Integer getCheckCount() {
    return this.CheckCount;
  }

  public void setCheckCount(Integer CheckCount) {
    this.CheckCount = CheckCount;
  }

  public Set<AcUserToGroup> getSetOfAcUserToGroup() {
    return this.SetOfAcUserToGroup;
  }

  public void setSetOfAcUserToGroup(Set<AcUserToGroup> setOfAcUserToGroup) {
    this.SetOfAcUserToGroup = setOfAcUserToGroup;
  }
}


AcUserToGroup.java
Code:
public class AcUserToGroup  implements java.io.Serializable {

// Fields   
  private de.psb_gmbh.main.business.persistence.AcUserToGroupId id;
  private java.lang.Integer CheckCount;

  // Constructors
  public AcUserToGroup() {
  }
 
  // Property accessors
  public AcUserToGroupId getId () {
      return this.id;
  }
 
  public void setId (AcUserToGroupId id) {
      this.id = id;
  }
 
  public Integer getCheckCount () {
      return this.CheckCount;
  }
 
public void setCheckCount (Integer CheckCount) {
      this.CheckCount = CheckCount;
  }
}




AcUserToGroupId.java
Code:
public class AcUserToGroupId implements java.io.Serializable {

  // Fields
  private AcGroup AcGroup;
  private AcUser AcUser;

  // Constructors
  public AcUserToGroupId() {
  }

  // Property accessors
  public de.psb_gmbh.main.business.persistence.AcGroup getAcGroup() {
    return this.AcGroup;
  }

  public void setAcGroup(
      de.psb_gmbh.main.business.persistence.AcGroup AcGroup) {
    this.AcGroup = AcGroup;
  }

  public de.psb_gmbh.main.business.persistence.AcUser getAcUser() {
    return this.AcUser;
  }

  public void setAcUser(de.psb_gmbh.main.business.persistence.AcUser AcUser) {
    this.AcUser = AcUser;
  }




Code between sessionFactory.openSession() and session.close():
Code:
    /** @ejb.interface-method view-type = "remote" */
    public void deleteAcUser(String userId) throws BusinessException{
      String msg =  "AcUserMgrBean.deleteAcUser("+userId+")";
      try {
        hsession = factory.getCurrentSession();
        hsession.createSQLQuery("DELETE FROM ac_user_to_group WHERE user_id='"+userId+"'");
        hsession.createSQLQuery("DELETE FROM ac_user WHERE user_id='"+userId+"'");
        log(msg);
      } catch (Exception e) {
        throw new BusinessException(msg, e.getCause());
      }
    }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.