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

  • Home
  • SEARCH
  • 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 8788833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:14:09+00:00 2026-06-13T22:14:09+00:00

I know that this will not work, which sucks IMO, but I am wondering

  • 0

I know that this will not work, which sucks IMO, but I am wondering what is my best solution. After some searching I have found out about ORM and hibernate. After finding out about them I have found many people who say its more hassle than it is worth and promotes laziness. Please can anyone point me in a good direction?

//Setup the weapon classes
logger.info("Initializing the weapon classes.");
stat = conn.prepareStatement("SELECT *" + 
                            " FROM " + DB_NAME + ".weapons");
rs = stat.executeQuery();
while (rs.next()) {
    Weapon rs.getString("name") = new Weapon(rs.getint("weapon_id"), rs.getString("name"), rs.getString("description"), rs.getString("filename"), rs.getint("rarity"), rs.getint("sell_price"), rs.getint("quantity_max"), rs.getint("slot"), rs.getint("level_requirement"), rs.getint("strength_requirement"), rs.getint("dexterity_requirement"), rs.getint("intelligence_requirement"), rs.getint("enchanted_increase"), rs.getint("enchanted_cost"), rs.getint("hit_min"), rs.getint("hit_max"), rs.getint("speed"), rs.getint("elemental_type"), rs.getint("elemental_hit_min"), rs.getint("elemental_hit_max"));
}

I know this has been asked many times, but I am just finding so many contradictory opinions. 🙁

  • 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-13T22:14:10+00:00Added an answer on June 13, 2026 at 10:14 pm

    Using an ORM depends on your project size. Personally, and by looking at your understanding of Java, I would not recommend that you jump into hibernate and such for now. I would suggest that you play directly with SQL first so you have a better understanding of persistence.

    As for the code you posted, here is what you could do :

    //Setup the weapon classes
    logger.info("Initializing the weapon classes.");
    stat = conn.prepareStatement("SELECT *" + 
                                " FROM " + DB_NAME + ".weapons");
    
    HashMap<String, Weapon> weapons = new HashMap<String, Weapon>();
    
    rs = stat.executeQuery();
    while (rs.next()) {
        Weapon weapon = new Weapon()
            .setId(rs.getint("weapon_id"))
            .setName(rs.getString("name"))
            .setDescription(rs.getString("description"))
            .setFilename(rs.getString("filename"))
            .setRarity(rs.getint("rarity"))
            .setSellPrice(rs.getint("sell_price"))
            .setQuantityMax(rs.getint("quantity_max"))
            .setSlot(rs.getint("slot"))
            .setLvlRequirement(rs.getint("level_requirement"))
            .setStrRequirement(rs.getint("strength_requirement"))
            .setDexRequirement(rs.getint("dexterity_requirement"))
            .setIntRequirement(rs.getint("intelligence_requirement"))
            .setEnchantedInc(rs.getint("enchanted_increase"))
            .setEnchantedCost(rs.getint("enchanted_cost"))
            .setHitMin(rs.getint("hit_min"))
            .setHitMax(rs.getint("hit_max"))
            .setSpeed(rs.getint("speed"))
            .setElementalType(rs.getint("elemental_type"))
            .setElementalHitMin(rs.getint("elemental_hit_min"))
            .setElementalHitMax(rs.getint("elemental_hit_max"));
    
        weapons.put(rs.getString("name"), weapon);
    }
    

    Avoid having a constructor (or even a method!) with so many arguments. Unless you are exporting your class to a third party or exposing it to some user plugins and don’t want anyone to change the internal values, don’t worry about setters! Then each set* methods return this so they can be chained. For example :

    public Weapon setHitMax(int max) {
        this.hitMax = max;
        return this;
    }
    

    And you can, then access your weapons using the Map. Like, for example :

    weapons.get("sword").getHitMax();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this feature will be deprecated in C++0x, but for me as
I realize that you can't 100% know that this will work in all browsers.
I know that this line of code will make the cell text-wrap: $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setWrapText(true); 'D1'
Would anyone happen to know a trick that will keep this MSBuild task from
I know that this sort of question has been asked here before, but still
I know that this is a newbie question but I am a newbie so
I know that this has already been asked here but the answer (using a
I hope that this question will not have the same luck with this one
I know that this question must have been asked and answered a million times,
I know that this question had already been asked a couple of times before,

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.