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 6248557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:04:51+00:00 2026-05-24T13:04:51+00:00

@Override public LinkedHashSet <String> listHotels() { Query query = em.createNativeQuery(select * from Hotel); LinkedHashSet

  • 0
@Override
public LinkedHashSet <String> listHotels() {
   Query query  = em.createNativeQuery("select  * from Hotel");
   LinkedHashSet <String> hotel= query.getResultList();
   return hotel;
}

I am getting a Warning saying incompatible types. query.getResultList(); returns a List, but what I want the method to return is a LinkedHashSet.

The reason why I’m using a LinkedHashSet here, is to avoid duplicate values being entered to the DB. I will call the method listHotels() first, and check if it has already contains the value and if doesn’t I’ll save the values to the DB

EDIT

    public void saveHotel(Hotel hotel) {
    if (hotel.getId() ==null){
        em.persist(hotel);
    } else {
        em.merge(hotel);
    }
}

THis is how i save records to my DB

  • 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-05-24T13:04:51+00:00Added an answer on May 24, 2026 at 1:04 pm

    You can not map a List to a Set. If you just want to eliminate duplicate then you can do so using your DB query

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

Sidebar

Related Questions

override public function set data(value:object):void { super.data = value } Is this function only
When running my @Override public void updateScene(int x, int y) The code the runs
Inside public class IAmHere extends Activity implements LocationListener { i have @Override public void
I want to override public boolean equals(Object obj) function, for name and age, in
Can someone explain to me why @Override public void fooMethod(Class<?> c) doesn't override public
I have this code: public class Home extends Activity{ @Override public void onCreate(Bundle savedInstanceState)
I tried to do this @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); t=new
When I call intent public class TInfo extends ListActivity implements OnSharedPreferenceChangeListener{ @Override public void
I have two question on this code public class Override { private void f()
I have the following broadcast receiver: public class MyRingModeReceiver extends BroadcastReceiver { @Override public

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.