Low Level Database Access: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann No edit summary |
imported>Hendrik Brummermann |
||
| Line 25: | Line 25: | ||
== Extending a provided DAO == |
== Extending a provided DAO == |
||
DAO classes should never be instantiated directly. Instead you should (and marauroa does) use the DAORegistry. This allows you to write a subclass of a DAO provided by marauroa and register it instead. If you are familiar with Spring, this is a similar concept. But without all the bulk of xml configuration files, parameter injection and interfaces with only one single implementation. |
|||
Imagine you want to subclass the CharacterDAO with your class SomeGameCharacterDAO: |
|||
<source lang="java"> |
|||
public class SomeGameCharacterDAO extends CharacterDAO { |
|||
... |
|||
</source> |
|||
You simply register it as |
|||
<source lang="java"> |
|||
DAORegistry.get().register(CharacterDAO.class, new SomeGameCharacterDAO()); |
|||
</source> |
|||
Note: In the register call the first parameter is the parent class you want to replace. |
|||
== Updating the database structure == |
== Updating the database structure == |
||