Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:20:33+00:00 2026-06-17T22:20:33+00:00

public abstract class BaseDAO<T extends BaseDTO> { public Integer create(T dto) { } public

  • 0
    public abstract class BaseDAO<T extends BaseDTO> {

        public Integer create(T dto) {

        }
        public Integer update(T dto) {

        }
        public Integer delete(T dto) {

       }

     }


    public class JobDAO extends BaseDAO<JobDTO> {

        public JobDAO(Connection conn) {
            super(conn);
        }

        @Override
        public String getDBTableName() {
            return "JobTABLE";
        }
    }


    public class BaseDTO {

        protected Integer ID;

        public Integer getID() {
            return ID;
        }

        public void setID(Integer ID) {
            this.ID = ID;
        }
    }


    public class JobDTO extends BaseDTO {

        Integer employerID;
        //getter
        //setter

     }



   public class Job_GUI extends javax.swing.JFrame {
    //GUI properties
    }

I am trying to understandModel, View, Controller Convention and I want to applyMVC to above class structures I have which consist of Data Transfer and Access Objects. What I’m failing to understand, is my structure above MVC? if so, what is the model? I’m guessing the DTO are themselves Model. Job_GUI is a View which I know already, but what is the Controller??

I want to directly write the actionPerformed codes in the Job_GUI itself, something like this snippet to create a job in db:

JobDAO jdao = new JobDAO(conn);
           //create object jobDTO to hold all form values to be passed to JobDAO
           final JobDTO jobDTO = new JobDTO();
           //populating JobDTO with values from form
           jobDTO.setEmployerID(id);
           jobDTO.setDescription(description.getText());
           jobDTO.setTitle(txtTitle.getText());
           jdao.create(jobDTO);

but should the above be in the Job_GUI class itself or somewhere else. If I were to insert the above snippet in Job_GUI am I moving away from the MVC convention as such? Where would you put the above snippet? The confusion lies in identifying which is the controller class out of all that I have if I were to use the DTO,DAO Design Pattern for database interaction.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:20:34+00:00Added an answer on June 17, 2026 at 10:20 pm
           JobDAO jdao = new JobDAO(conn);
           //create object jobDTO to hold all form values to be passed to JobDAO
           final JobDTO jobDTO = new JobDTO();
           //populating JobDTO with values from form
           jobDTO.setEmployerID(id);
           jobDTO.setDescription(description.getText());
           jobDTO.setTitle(txtTitle.getText());
           jdao.create(jobDTO);
    

    In above code you basically doing job of Controller because you assigning values to your DTO and then calling create method of your DAO. This is what Controller is supposed to do. So you are right on this part except one small correction :

        JobDAO jdao = new JobDAO(conn);  //not preferable
        JobDAO jdao = new JobDAO();  //preferred inside Controller class
    

    Will suggest you to keep connection specific code inside your DAO. Your Controller class shouldn’t know about your DB connection. You can perform this inside your create/update/delete methods of DAO.

    DAO where you actually interact with DB is part of MODEL in MVC.

    Just keep in mind few things :

    • MVC (architectural design pattern) stresses on separation of concern. So make sure that you have well defined classes for View, Controller and Model
    • Your class names should convey which component it belongs to (BaseDAO etc)
    • Controller controls View and Model. So your View and Model should not be aware of each other.

    And as you mentioned that you are already clear with View. So i haven’t put any explanation on that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

classes: public abstract class BaseHolidayPackageVariant { private Integer variantId; private HolidayPackage holidayPackage; private String
public abstract class GenericTests<T extends Number> { protected abstract T getT(); @Test public void
public abstract class ASTNode3 extends ASTNode { ASTNode child1; ASTNode child2; ASTNode child3; public
public abstract class Main implements Comparable { public static void main(String[] args) { Integer[]
public abstract class Mother { } public class Daughter extends Mother { } public
Examine the code below public abstract class ClassA<ClassBType extends ClassB<ClassCType>,ClassCType extends ClassC> { public
I have a class: public abstract class LogicGate extends JPanel implements PropertyChangeListener { private
My class starts with public abstract class LastActionHero<H extends Hero>(){ Now somewhere in the
I have a class public abstract class AbstractE<T, E extends Enum<E> & Flags> {
public abstract class JsonElement extends Object A class representing an element of Json. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.