You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2008/09/16 16:33:16 UTC
svn commit: r695907 - in /labs/magma/trunk/foundation-database: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/magma/ src/main/java/org/apache/magma/database/
src/test/ src/test/java/ src/test/jav...
Author: simoneg
Date: Tue Sep 16 07:33:15 2008
New Revision: 695907
URL: http://svn.apache.org/viewvc?rev=695907&view=rev
Log:
Initial import.
Added:
labs/magma/trunk/foundation-database/pom.xml
labs/magma/trunk/foundation-database/src/
labs/magma/trunk/foundation-database/src/main/
labs/magma/trunk/foundation-database/src/main/java/
labs/magma/trunk/foundation-database/src/main/java/org/
labs/magma/trunk/foundation-database/src/main/java/org/apache/
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddColumnAnnotationParsing.aj
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddDefaultJPAValidation.aj
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/DatabaseValidator.java
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/WarnAgainstBadUsage.aj
labs/magma/trunk/foundation-database/src/test/
labs/magma/trunk/foundation-database/src/test/java/
labs/magma/trunk/foundation-database/src/test/java/org/
labs/magma/trunk/foundation-database/src/test/java/org/apache/
labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/
labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/
labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/TestDatabaseValidator.java
labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/ValidableBean.java
Added: labs/magma/trunk/foundation-database/pom.xml
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/pom.xml?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/pom.xml (added)
+++ labs/magma/trunk/foundation-database/pom.xml Tue Sep 16 07:33:15 2008
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>magma-parent</artifactId>
+ <version>1</version>
+ </parent>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>foundation-database</artifactId>
+ <name>Foundation Database</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <description>
+ Provides foundation for bean persistence on a database
+ </description>
+ <packaging>magma</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.magma.tools</groupId>
+ <artifactId>maven-magma-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>foundation-beans</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_3.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>foundation-validation</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Added: labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddColumnAnnotationParsing.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddColumnAnnotationParsing.aj?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddColumnAnnotationParsing.aj (added)
+++ labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddColumnAnnotationParsing.aj Tue Sep 16 07:33:15 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+import javax.persistence.Column;
+import java.lang.annotation.Annotation;
+import org.apache.magma.validation.Validator;
+import org.apache.magma.validation.Validators;;
+
+public aspect AddColumnAnnotationParsing {
+
+ Validator around(Annotation annotation) :
+ execution(Validator Validators.getValidatorFor(Annotation)) && args(annotation) {
+
+ if (annotation.annotationType().equals(Column.class)) {
+ DatabaseValidator val = new DatabaseValidator();
+ Validators.setupValidator(annotation, val);
+ return val;
+ } else {
+ return proceed(annotation);
+ }
+ }
+
+}
Added: labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddDefaultJPAValidation.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddDefaultJPAValidation.aj?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddDefaultJPAValidation.aj (added)
+++ labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/AddDefaultJPAValidation.aj Tue Sep 16 07:33:15 2008
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+import org.apache.magma.beans.PropertyInfo;
+import java.beans.PropertyDescriptor;
+import org.apache.magma.validation.AddValidatorInPropertyInfo;
+import javax.persistence.Entity;
+import javax.persistence.Embeddable;
+import javax.persistence.MappedSuperclass;
+import org.apache.magma.validation.CompoundValidator;
+import org.apache.magma.validation.Validators;
+import org.apache.magma.validation.Validator;
+
+public aspect AddDefaultJPAValidation {
+
+ declare precedence : AddValidatorInPropertyInfo, AddDefaultJPAValidation;
+
+ after(PropertyInfo info, Class beanClass) :
+ execution(* PropertyInfo.init(PropertyDescriptor, Class)) && this(info) && args(.., beanClass) {
+
+ if (!info.getType().equals(String.class)) return;
+
+ CompoundValidator val = info.getValidator();
+ if (val != null && val.getValidator(DatabaseValidator.class) != null) return;
+
+ boolean isjpa = false;
+ isjpa |= beanClass.isAnnotationPresent(Entity.class);
+ isjpa |= beanClass.isAnnotationPresent(Embeddable.class);
+ isjpa |= beanClass.isAnnotationPresent(MappedSuperclass.class);
+
+ if (!isjpa) return;
+
+ DatabaseValidator dbv = new DatabaseValidator();
+ dbv.setLength(255);
+
+ Validators.addValidator(info, dbv);
+ }
+
+
+}
Added: labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java (added)
+++ labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java Tue Sep 16 07:33:15 2008
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+import java.util.List;
+
+/**
+ * Represents a database. This is just a mock class, concrete database implementations
+ * will catch instantiations of this class and replace it with the proper implementation.
+ * Anyway, as a common standard, this interface is JPQL based, so implementations that
+ * does not support JPQL directly will have to translate the query language.
+ * @author Simone Gianni <si...@apache.org>
+ */
+public class Database {
+
+ /**
+ * Loads an entity of the given class with the given id.
+ * <p>
+ * As an example :
+ * <code>
+ * Database db = new Database();
+ * Person p = db.load(Person.class, 1);
+ * </code>
+ * will load the person with id=1.
+ * </p>
+ * <p>
+ * Quite frequently, the id will be a single value, and usually
+ * it will be a numeric type or if a more complex system of keys is required
+ * it will be encapsulated in a class.
+ * </p>
+ * @param <T> The class of the bean we are trying to load.
+ * @param clazz The class of the bean we are trying to load.
+ * @param id The key (id) of the entity to load (or more than one if it's multi keyed).
+ * @return An instance of the entity, or null if not found.
+ */
+ public <T> T load(Class<T> clazz, Object... id) {
+ return null;
+ }
+
+ /**
+ * Executes a query on a certain entity class.
+ * <p>
+ * This method uses JPQL for the query part, but slightly simplified :
+ * <code>
+ * Database db = new Database();
+ * List<Person> list = db.query(Person.class,"WHERE x.name=:1", "Simone");
+ * </code>
+ * As you can see, there is no need to specify SELECT or to specify the class, basically the query is
+ * automatically prepended with "SELECT x FROM com.company.Person x ". Note that the entity is
+ * always named "x".
+ * </p>
+ * <p>
+ * This simplifies the most frequent case, and also reduces the number of typos while increasing compile
+ * time checking. If a more complex where statement is needed, it's possible to start the query with
+ * the "SELECT" keyword, in that case no modification to the string is done, and the
+ * </p>
+ * <p>
+ * To make a query that does not fetch a specific entity, but for example calculates some different data,
+ * it's possible to specify a non-entity class as first parameter. For example :
+ * <code>
+ * List<String> names = db.query(String.class, "SELECT x.name FROM Person x");
+ * </code>
+ * </p>
+ * @param <T> The class of elements returned by the query
+ * @param clazz The class of elements returned by the query
+ * @param query The JPQL query, eventually without the "SELECT x FROM ClassName x" part, as stated above.
+ * @param params The params to replace in the query.
+ * @return A List of entities of the specified class, ordered as eventually specified in the query.
+ */
+ public <T> List<T> query(Class<T> clazz, String query, Object... params) {
+ return null;
+ }
+
+ /**
+ * Executes a query that returns a single number.
+ * <p>
+ * This method is useful when the query needs to return a simple number, like a count or an average.
+ * For example :
+ * <code>
+ * Database db = new Database();
+ * int people = db.queryNumber("SELECT count(x) FROM Person x");
+ * </code>
+ * The return is of type number, because this method can also be used for queries that will return a
+ * floating point or very large number :
+ * <code>
+ * double avgSalary = db.queryNumber("SELECT AVG(x.salary) FROM Person x");
+ * long monthlyCost = db.queryNumber("SELECT SUM(x.salary) FROM Person x");
+ * </code>
+ * </p>
+ * @param query The query to execute
+ * @return The only number returned by the query.
+ */
+ public Number queryNumber(String query, Object... params) {
+ return 0;
+ }
+
+ /**
+ * Persists an entity, if its a new entity results in an INSERT, otherwise in an UPDATE.
+ * @param bean The entity to be persisted.
+ */
+ public void save(Object bean) {}
+
+ /**
+ * Deletes an entity.
+ * @param bean The entity to be deleted.
+ */
+ public void delete(Object bean) {}
+
+
+}
Added: labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/DatabaseValidator.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/DatabaseValidator.java?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/DatabaseValidator.java (added)
+++ labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/DatabaseValidator.java Tue Sep 16 07:33:15 2008
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.magma.basics.LocalizableString;
+import org.apache.magma.validation.Validator;
+
+public class DatabaseValidator implements Validator {
+
+ private boolean nullable = true;
+ private int length = -1;
+
+ public List<LocalizableString> validate(Object value) {
+ List<LocalizableString> ret = new ArrayList<LocalizableString>(1);
+ if (value == null) {
+ if (!nullable) {
+ ret.add(new LocalizableString("Cannot be null, as specified on database constraint"));
+ return ret;
+ }
+ } else if (value instanceof String && length != -1) {
+ if (((String)value).length() > length) {
+ ret.add(new LocalizableString("Cannot exceed {0} characters, as specified on database constraint", length));
+ return ret;
+ }
+ }
+ return null;
+ }
+
+ public boolean isNullable() {
+ return nullable;
+ }
+
+ public void setNullable(boolean nullable) {
+ this.nullable = nullable;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+}
Added: labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/WarnAgainstBadUsage.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/WarnAgainstBadUsage.aj?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/WarnAgainstBadUsage.aj (added)
+++ labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/WarnAgainstBadUsage.aj Tue Sep 16 07:33:15 2008
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+public aspect WarnAgainstBadUsage {
+
+ declare warning : set(Database+ *.*) || get(Database+ *.*) : "Magma: Database should not be stored in a field, but instantiated when needed!";
+
+}
Added: labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/TestDatabaseValidator.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/TestDatabaseValidator.java?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/TestDatabaseValidator.java (added)
+++ labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/TestDatabaseValidator.java Tue Sep 16 07:33:15 2008
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+import java.util.Arrays;
+
+import org.apache.magma.beans.BeanHandler;
+import org.apache.magma.validation.ValidationError;
+
+import org.junit.Test;
+
+
+public class TestDatabaseValidator {
+
+
+ @Test(expected=ValidationError.class)
+ public void nullSetters() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", null);
+ handler.setValue("uselessNumber", null);
+ handler.setValue("name", null);
+ handler.setValue("surname", null);
+ handler.commit();
+ }
+
+ @Test(expected=ValidationError.class)
+ public void nullName() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", 1);
+ handler.setValue("uselessNumber", 1);
+ handler.setValue("name", null);
+ handler.setValue("surname", "ciao");
+ handler.commit();
+ }
+
+ @Test(expected=ValidationError.class)
+ public void nullNumber() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", null);
+ handler.setValue("uselessNumber", 1);
+ handler.setValue("name", "ciao");
+ handler.setValue("surname", "ciao");
+ handler.commit();
+ }
+
+ @Test
+ public void allOk() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", 1);
+ handler.setValue("uselessNumber", 1);
+ handler.setValue("name", "ciao");
+ handler.setValue("surname", "ciao");
+ handler.commit();
+ }
+
+ @Test(expected=ValidationError.class)
+ public void checkDefaultValidation() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", 1);
+ handler.setValue("uselessNumber", 1);
+ handler.setValue("name", "ciao");
+ handler.setValue("surname", "ciao");
+ char[] chars = new char[1000];
+ Arrays.fill(chars, 'a');
+ handler.setValue("description", new String(chars));
+ handler.commit();
+ }
+
+ @Test(expected=ValidationError.class)
+ public void longName() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", null);
+ handler.setValue("uselessNumber", 1);
+ handler.setValue("name", "ciao01234567890123456789012345678901234567890123456789");
+ handler.setValue("surname", "ciao");
+ handler.commit();
+ }
+
+ @Test(expected=ValidationError.class)
+ public void longSurname() throws Exception {
+ ValidableBean bean = new ValidableBean();
+ BeanHandler handler = bean.handler();
+ handler.setValue("number", null);
+ handler.setValue("uselessNumber", 1);
+ handler.setValue("name", "ciao");
+ handler.setValue("surname", "ciao01234567890123456789012345678901234567890123456789");
+ handler.commit();
+ }
+
+
+}
Added: labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/ValidableBean.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/ValidableBean.java?rev=695907&view=auto
==============================================================================
--- labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/ValidableBean.java (added)
+++ labs/magma/trunk/foundation-database/src/test/java/org/apache/magma/database/ValidableBean.java Tue Sep 16 07:33:15 2008
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.database;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.apache.magma.beans.MagmaBean;
+
+@MagmaBean
+@Entity
+public class ValidableBean {
+
+ private long id;
+
+ private Integer number;
+ private Integer uselessNumber;
+ private String name;
+ private String surname;
+ private String description;
+
+ @Id
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @Column(nullable=false)
+ public Integer getNumber() {
+ return number;
+ }
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ public Integer getUselessNumber() {
+ return uselessNumber;
+ }
+ public void setUselessNumber(Integer uselessNumber) {
+ this.uselessNumber = uselessNumber;
+ }
+
+ @Column(nullable=false, length=50)
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Column(length=50)
+ public String getSurname() {
+ return surname;
+ }
+ public void setSurname(String surname) {
+ this.surname = surname;
+ }
+
+ // Nothing specified, should be limited to 255
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org