Search Results

Search found 2 results on 1 pages for 'nican'.

Page 1/1 | 1 

  • Hibernate, select by id or unique column

    - by Nican
    I am using hibernate for Java, and I want to be able to select users by id or by name from the database. Nice thing about Hibernate is that it caches the result by id, but I seem to be unable to make it cache by name. static Session openSession = Factory.openSession(); public static User GetUser(int Id) { return (User) openSession.get(User.class, new Integer(Id)); } public static User GetUser( String Name ){ return (User) openSession.createCriteria( User.class ). add( Restrictions.eq("username", Name) ). uniqueResult(); } If I use GetUser(1) many times, hibernate will only show that it executed the first time. But every time I use GetUser("user1"), hibernate shows that it is executing a new query to database. What would be the best way to have the string identifier be cached also?

    Read the article

  • PHP Detect Pages Genre/Category

    - by Alexwhin
    Hey, I was wondering if their was any sort of way to detect a pages genre/category. Possibly their is a way to find keywords or something? Unfortunately I don't have any idea so far, so I don't have any code to show you. But if anybody has any ideas at all, let me know. Thanks! EDIT @Nican Perhaps their is a way to set, let's say 10 category's (Entertainment, Funny, Tech). Then creating keywords for these category's (Funny = Laughter, Funny, Joke etc). Then searching through a webpage (maybe using a cUrl) for these keywords and assigning it to the right category. Hope that makes sense.

    Read the article

1