de.hs_rm.cs.lecturenotes.server.core.persistence.dao
Class ExerciseDAO

java.lang.Object
  extended by de.hs_rm.cs.lecturenotes.server.core.persistence.dao.AbstractDAO<Exercise>
      extended by de.hs_rm.cs.lecturenotes.server.core.persistence.dao.ExerciseDAO
All Implemented Interfaces:
IDAO<Exercise>

public final class ExerciseDAO
extends AbstractDAO<Exercise>

Data Access Object for System Entity Paragraph. A bunch of core editor functionality resides in LectureSelectHandler.

Version:
$LastChangedRevision: 274 $
Author:
Enrico Homann

Field Summary
static java.lang.String SQL_TABLENAME
          SQL Table Name.
 
Fields inherited from class de.hs_rm.cs.lecturenotes.server.core.persistence.dao.AbstractDAO
SQL_DELETEALL_TEMPLATE, SQL_DROP_TEMPLATE
 
Fields inherited from interface de.hs_rm.cs.lecturenotes.server.core.persistence.dao.IDAO
SQLERRORCODE_DUPLICATE_ENTRY
 
Constructor Summary
ExerciseDAO(SQLConnection db)
          DAO Constructor.
 
Method Summary
 java.lang.Long createEntity(Exercise entity)
          Creates an entity of type T and returns the inserted id.
 java.util.List<Exercise> getEntityListBySQL(java.lang.String sql)
          Will return all lectures by String sql.
 java.util.List<Exercise> getExercisesByParaId(long paraId, ExerciseAttributeEnum orderAttribute, SQLSortDirectionEnum sortDirection)
          Will return a List of Exercise objects for a Paragraph with long paraId.
 java.lang.Integer hardDeleteEntity(Exercise entity)
          Hard deletes Exercise.
 java.lang.Integer updateEntity(Exercise entity)
          Will update a Exercise entity and return the number of rows that were updated, which must be one.
 
Methods inherited from class de.hs_rm.cs.lecturenotes.server.core.persistence.dao.AbstractDAO
createEntity, deleteTableContents, dropTable, executeCreateSQL, executeUpdateSQL, getDb, setDb
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQL_TABLENAME

public static final java.lang.String SQL_TABLENAME
SQL Table Name.

See Also:
Constant Field Values
Constructor Detail

ExerciseDAO

public ExerciseDAO(SQLConnection db)
DAO Constructor.

Parameters:
db - SQLConnection connection
Method Detail

getEntityListBySQL

public java.util.List<Exercise> getEntityListBySQL(java.lang.String sql)
Will return all lectures by String sql. This method does not fetch the paragraphs.

Parameters:
sql - String
Returns:
Lecture

getExercisesByParaId

public java.util.List<Exercise> getExercisesByParaId(long paraId,
                                                     ExerciseAttributeEnum orderAttribute,
                                                     SQLSortDirectionEnum sortDirection)
Will return a List of Exercise objects for a Paragraph with long paraId.

Parameters:
paraId - long
orderAttribute - ExerciseAttributeEnum
sortDirection - SQLSortDirectionEnum
Returns:
List of Exercise

createEntity

public java.lang.Long createEntity(Exercise entity)
                            throws java.sql.SQLException
Description copied from interface: IDAO
Creates an entity of type T and returns the inserted id. Throws SQLException in case of a duplicated entry or other DBMS problems.

Parameters:
entity - T
Returns:
Long Id of the freshly inserted row. Must be not null and should be above 0.
Throws:
java.sql.SQLException - Exception thrown. Here to indicate a duplicate entry to the outside world.

updateEntity

public java.lang.Integer updateEntity(Exercise entity)
Will update a Exercise entity and return the number of rows that were updated, which must be one. If the number is not one a failure had occurred. Notice: Ownership will not be updated

Parameters:
entity - Exercise.
Returns:
Integer Number of rows that were updated

hardDeleteEntity

public java.lang.Integer hardDeleteEntity(Exercise entity)
Hard deletes Exercise.

Parameters:
entity - Exercise
Returns:
Integer