Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 18 | Rev 19 | ||
|---|---|---|---|
| Line 8... | Line 8... | ||
| 8 | import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
8 | import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
| 9 | import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
9 | import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
| 10 | import ch.ffhs.webE.domain.*; |
10 | import ch.ffhs.webE.domain.*; |
| 11 | 11 | ||
| 12 | public class UserDAOImpl implements UserDAO { |
12 | public class UserDAOImpl implements UserDAO { |
| - | 13 | ||
| 13 | @SessionTarget |
14 | @SessionTarget |
| 14 | Session session;
|
15 | Session session;
|
| 15 | @TransactionTarget |
16 | @TransactionTarget |
| 16 | Transaction transaction;
|
17 | Transaction transaction;
|
| 17 | 18 | ||
| Line 34... | Line 35... | ||
| 34 | } catch (Exception e) { |
35 | } catch (Exception e) { |
| 35 | transaction.rollback(); |
36 | transaction.rollback(); |
| 36 | e.printStackTrace(); |
37 | e.printStackTrace(); |
| 37 | }
|
38 | }
|
| 38 | }
|
39 | }
|
| - | 40 | ||
| - | 41 | /**
|
|
| - | 42 | * Returns a single user with this user name (used for login)
|
|
| - | 43 | * @param username: String - entire user name
|
|
| - | 44 | * @return User: Returns a user object if something is found. If not, null is returned
|
|
| - | 45 | */
|
|
| - | 46 | public User searchUsername(String username) { |
|
| - | 47 | User user = null; |
|
| - | 48 | ||
| - | 49 | try { |
|
| - | 50 | user = (User) session.createQuery( |
|
| - | 51 | "FROM User " +
|
|
| - | 52 | "WHERE username = :username") |
|
| - | 53 | .setParameter("username", username) |
|
| - | 54 | .uniqueResult(); |
|
| - | 55 | } catch (Exception e) { |
|
| - | 56 | //TODO: Log error
|
|
| - | 57 | }
|
|
| - | 58 | return user; |
|
| - | 59 | }
|
|
| 39 | }
|
60 | }
|