Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Deleting a record from one table deletes record from another table too

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two tables, Employee and Supervisor. I am using Spring JDBC for my database actions and MySQL as my database. I don't have any relation between an Employee and Supervisor. But as part of the front end web application, I can assign a supervisor to an employee. So, after doing that, when I try to delete a supervisor who has an employee assigned, the action deletes all employees whether they have that supervisor assigned to them or not. I don't understand what's happening. Here is my spring-config.xml:
<beans>
<bean id="MYSQL_DATASOURCE" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/employeereview" />
<property name="username" value="root" />
<property name="password" value="sharmav0416" />
</bean>
<!-- Configure DAO -->
<bean id="SUPERVISOR_DAO" class="employeereview.supervisor.dao.SupervisorDAOImpl">
<property name="dataSource">
<ref bean="MYSQL_DATASOURCE"></ref>
</property>
</bean>
<bean id="EMPLOYEE_DAO" class="employeereview.employee.dao.EmployeeDAOImpl">
<property name="dataSource">
<ref bean="MYSQL_DATASOURCE"></ref>
</property>
</bean>
<!-- Configure Business Service -->
<bean id="SUPERVISOR_BUSINESS"
class="employeereview.supervisor.business.SupervisorBusinessImpl">
<property name="dao">
<ref bean="SUPERVISOR_DAO"></ref>
</property>
</bean>
<bean id="EMPLOYEE_BUSINESS"
class="employeereview.employee.business.EmployeeBusinessImpl">
<property name="dao">
<ref bean="EMPLOYEE_DAO"></ref>
</property>
</bean>

Any help would be greatly appreciated.

Thanks

Sharma
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic