This discussion is archived
7 Replies Latest reply: Feb 6, 2013 8:20 AM by 800411 RSS

What is best 'LINQ like' in java

800411 Newbie
Currently Being Moderated
Hello All

I am looking for something in java that is working similar to LinQ & Entity Framework in .Net.
What is the best do we have out there now

Thank you
  • 1. Re: What is best 'LINQ like' in java
    Kayaman Guru
    Currently Being Moderated
    That would be JPA.
  • 2. Re: What is best 'LINQ like' in java
    800411 Newbie
    Currently Being Moderated
    Thank you,
    I will play with it. I was completely in java until recent few years working on some .Net projects that give me more things to learn and to compare with java. I begin liking the way EF and linQ work. Not only we can query the database but also we can query from the set of data, and/or the combination [join] between database tables and the data sets.
  • 3. Re: What is best 'LINQ like' in java
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    mycoffee wrote:
    but also we can query from the set of data, and/or the combination [join] between database tables and the data sets.
    Keeping in mind of course that there are reasons why database queries exist versus doing it entirely in client code.
  • 4. Re: What is best 'LINQ like' in java
    800411 Newbie
    Currently Being Moderated
    jschell wrote:
    mycoffee wrote:
    but also we can query from the set of data, and/or the combination [join] between database tables and the data sets.
    Keeping in mind of course that there are reasons why database queries exist versus doing it entirely in client code.
    In MVC3.0 the LINQ queries are not in the client[View] code, it is used in the Controller. I like linQ the way it can do with the data sets. In JDBC, after we query the database, we can only loop through the result set once. I have to build my own disconnected result set, fill it up with the result set and loop through the data to apply the logic but sometime it is not as easy as LINQ.
  • 5. Re: What is best 'LINQ like' in java
    Kayaman Guru
    Currently Being Moderated
    mycoffee wrote:
    I have to build my own disconnected result set, fill it up with the result set and loop through the data to apply the logic but sometime it is not as easy as LINQ.
    Don't do that, use a RowSet instead:
    http://stackoverflow.com/questions/8217493/implementations-of-rowset-cachedrowset-etc
    http://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html
  • 6. Re: What is best 'LINQ like' in java
    800411 Newbie
    Currently Being Moderated
    Kayaman wrote:
    mycoffee wrote:
    I have to build my own disconnected result set, fill it up with the result set and loop through the data to apply the logic but sometime it is not as easy as LINQ.
    Don't do that, use a RowSet instead:
    http://stackoverflow.com/questions/8217493/implementations-of-rowset-cachedrowset-etc
    http://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html
    Thank you. I didn't know it.
    but I think it is the same idea. The difference is my DisconnectedResultSet class I built my own instead of JdbcRowSet
    // From http://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html
    stmt = con.createStatement(
               ResultSet.TYPE_SCROLL_SENSITIVE,
               ResultSet.CONCUR_UPDATABLE);
    rs = stmt.executeQuery("select * from COFFEES");
    jdbcRs = new JdbcRowSetImpl(rs);
    // My code.
    stmt = con.prepareStatement(sql);
    rs = stmt.executeQuery();
    DisconnectedResultSet myRs = new DisconnectedResultSet(rs);
  • 7. Re: What is best 'LINQ like' in java
    800411 Newbie
    Currently Being Moderated
    Kayaman wrote:
    mycoffee wrote:
    I have to build my own disconnected result set, fill it up with the result set and loop through the data to apply the logic but sometime it is not as easy as LINQ.
    Don't do that, use a RowSet instead:
    http://stackoverflow.com/questions/8217493/implementations-of-rowset-cachedrowset-etc
    http://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html
    Ahh. So actually, we can update the database when changing the data from JdbcRowSet !!!!!!!!!!! That is much better, even I think the data need to be from the tables, not from the views or joins. Will test it

    This is from http://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html
    Updating Column Values

    You update data in a JdbcRowSet object the same way you update data in a ResultSet object.

    Assume that the Coffee Break owner wants to raise the price for a pound of Espresso coffee. If the owner knows that Espresso is in the third row of the jdbcRs object, the code for doing this might look like the following:

    jdbcRs.absolute(3);
    jdbcRs.updateFloat("PRICE", 10.99f);
    jdbcRs.updateRow();

    The code moves the cursor to the third row and changes the value for the column PRICE to 10.99, and then updates the database with the new price.

    Calling the method updateRow updates the database because jdbcRs has maintained its connection to the database. For disconnected RowSet objects, the situation is different.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points