code snippets

Snippet 1

package my.model {

	import com.google.inject.*

	entity House {
		@Inject
		var javax.naming.Context context
		var Type type
		embedds Address address

		contains Window[*] windows opposite house
		refers Window[*] openWindows

		/**
		 * Returns number of open windows
		 */
		def int numberOfOpenWindows(){
			return openWindows.size
		}
	}

	entity Window {
		container House house opposite windows		
	}

	embeddable entity Address {
		var String street
		var String postalCode
	}

	enum Type {
		OLD, NEW
	}
}

Snippet 2

package my.model {

    entity House {

        var String name
        var String[*] manyNames
        var List<String> alsoManyNames
        var List<String>[*] manyListsOfNames

        var Type typeEnum
    }

    enum Type {
        OLD, NEW
    }
}

Snippet 3

package my.model {

    entity House {
        refers Person owner opposite houses
        refers Person[*] livingInHouse
    }

    entity Person {
        refers House[*] houses opposite owner
    }
}

Snippet 4

package my.model {

	entity House {
		contains Window[*] windows opposite house
		refers Window[*] openWindows
	}

	entity Window {
		container House house opposite windows		
	}
}

Snippet 5

package my.model {

	import google.guice.*

	entity House {
		embedds Address address
	}

	embeddable entity Address {
		var String street
		var String postalCode
	}
}

Snippet 6

package my.model {

	import com.google.inject.*

	entity House {
		refers Window[*] openWindows

		/**
		 * Returns a set containing the names of the
		 * windows UPPERCASE. 
		 */
		def Set toWindowNamesUppercase(){
			return openWindows.map([e | e.name.toUpperCase]).toSet
		}
	}

	entity Window {
		var String name
	} 
}

Snippet 7

package my.model {

	exclude @javax.persistence.Entity
	@java.lang.Deprecated
	@javax.persistence.OneToMany(cascade=javax::persistence::CascadeType::REMOVE)
	entity House {
		var id int id
	}

}
}

Snippet 8

generator settings {
	compilerType=org.lunifera.annotation.processor.JPA
}

package my.test {
	entity Library {
		var id long id
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: