Permalink
Browse files

Persist is compilable, maybe works...

  • Loading branch information...
1 parent 118dc39 commit 5d5ce556efd7d3c7c5c8a6e6b067d64b9a4a2718 siroky committed Apr 10, 2012
@@ -0,0 +1,3 @@
+<component name="ProjectDictionaryState">
+ <dictionary name="Honza" />
+</component>
@@ -99,6 +99,7 @@
<inspection_tool class="CyclicClassDependency" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CyclicPackageDependency" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CyclomaticComplexity" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoreEqualsMethod" value="false" />
<option name="m_limit" value="10" />
</inspection_tool>
<inspection_tool class="DeclareCollectionAsInterface" enabled="true" level="WARNING" enabled_by_default="true">
@@ -180,7 +181,8 @@
</inspection_tool>
<inspection_tool class="LoggingConditionDisagreesWithLogStatement" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MagicNumber" enabled="true" level="WARNING" enabled_by_default="true">
- <option name="m_ignoreInHashCode" value="true" />
+ <option name="ignoreInHashCode" value="true" />
+ <option name="ignoreInTestCode" value="false" />
</inspection_tool>
<inspection_tool class="MethodCount" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_limit" value="20" />
@@ -72,7 +72,15 @@ object PayolaDB extends Schema
}
}
- def save(entity: cz.payola.common.entities.Entity) = {
+ def persist(persistable: PersistableEntity) {
+ if (persistable.isPersisted) {
+ persistable.update
+ } else {
+ persistable.save
+ }
+ }
+
+ /*def save(entity: cz.payola.common.entities.Entity) = {
transaction {
// Get properly typed entity
@@ -105,7 +113,7 @@ object PayolaDB extends Schema
table.insert(e)
} */
}
- }
+ }*/
def getUserById(id: String) : Option[User] = {
_getByID(users, id)
@@ -1,18 +0,0 @@
-package cz.payola.data.entities
-
-import PayolaDB._
-import org.squeryl.KeyedEntity
-
-trait Persistable extends KeyedEntity[String]{
-
- def persist
- /* = {
- if(isPersisted) {
- update
- }
- else {
- save
- }
- }
- */
-}
@@ -0,0 +1,10 @@
+package cz.payola.data.entities
+
+import org.squeryl.KeyedEntity
+
+trait PersistableEntity extends KeyedEntity[String]
+{
+ def persist() {
+ PayolaDB.persist(this)
+ }
+}

0 comments on commit 5d5ce55

Please sign in to comment.