Geert,
i'm using the generic query mgr; the account bean is pasted below.
Thanks,
Emmanuel
--- Account.java ---
package friends.beans;
import java.util.Calendar;
import java.util.Date;
import com.uwyn.rife.cmf.CmfProperty;
import com.uwyn.rife.cmf.CmfValidation;
import friends.util.Countries;
public class Account extends CmfValidation {
protected void activateValidation() {
addConstraint(new
CmfProperty(ID).identifier(true).editable(false));
addConstraint(new
CmfProperty(USER_ID).notNull(true).unique(true));
addConstraint(new
CmfProperty(EMAIL).notNull(true).notEmpty(true).email(true)/* (relaxed
for testing).unique(true)*/);
addConstraint(new CmfProperty(SEX).inList(SEX_IDS));
addConstraint(new
CmfProperty(COUNTRY).inList(Countries.getIds(COUNTRY)));
addConstraint(new CmfProperty(CREATED).notNull(true));
}
public Date getBirthdate() {
return birthdate;
}
public String getCountry() {
return country;
}
public Date getCreated() {
return created;
}
public String getEmail() {
return email;
}
public String getFirstname() {
return firstname;
}
public int getId() {
return id;
}
public String getLastname() {
return lastname;
}
public String getLocation() {
return location;
}
public String getSex() {
return sex;
}
public long getUserId() {
return userId;
}
public int getVisibility() {
return visibility;
}
public void setBirthdate(Date dob) {
this.birthdate = dob;
}
public void setCountry(String countryId) {
this.country = countryId;
}
public void setCreated(Date created) {
this.created = created;
}
public void setEmail(String email) {
this.email = email;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setId(int id) {
this.id = id;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public void setLocation(String location) {
this.location = location;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setUserId(long n) {
this.userId = n;
}
public void setVisibility(int visibility) {
this.visibility = visibility;
}
public static final String ID = "id";
//TODO: move into the RoleUser class
public static final String USER_ID = "userId";
public static final String EMAIL = "email";
public static final String SEX = "sex";
public static final String FIRSTNAME = "firstname";
public static final String LASTNAME = "lastname";
public static final String CREATED = "created";
public static final String COUNTRY = "country";
public static final String LOCATION = "location";
public static final int MAX_AGE = 85;
public static final int MIN_AGE = 12;
private static final String[] SEX_IDS = {"M", "F", "X"};
private int id = -1;
private Date birthdate;
private Date created = Calendar.getInstance().getTime();
private String email;
//TODO: move profile specific info
private String firstname;
private String lastname;
private long userId = -1;
private String sex;
private String country;
private String location;
private int visibility = 0;
}
On 11/27/05, Geert Bevin <[EMAIL PROTECTED]> wrote:
> Hi Emmanuel,
>
> did you use the generic query manager or the content query manager to
> create the account table?
> What does your account been look like?
>
> Best regards,
>
> Geert
>
> On 27-nov-05, at 22:45, Emmanuel Okyere wrote:
>
> > Geert,
> >
> > I keep running into the exception pasted below, when I try to do a
> > simple insertion into one of my tables. This happens while trying to
> > test the app with testng, using the RunWithEngineClassLoader that is
> > also pasted. Any pointers?
> >
> > thanks,
> > Emmanuel
> >
> > <target name="run" depends="build">
> > <!--delete dir="${out.dir}" /-->
> >
> > <!--testng outputDir="${out.dir}">
> > <classpath>
> > <path refid="tests.classpath"/>
> > </classpath>
> > <xmlfileset dir="${basedir}" includes="testng.xml"/>
> > </testng-->
> > <java classname="com.uwyn.rife.test.RunWithEngineClassLoader"
> > dir="${basedir}"
> > fork="yes"
> > failonerror="yes">
> > <classpath>
> > <path refid="tests.classpath" />
> > <pathelement location="${build.classes}"/>
> > </classpath>
> > <jvmarg line="-ea" />
> > <arg line="org.testng.TestNG testng.xml" />
> > </java>
> >
> > </target>
> >
> >
> >
> > --- EXCEPTION ---
> >
> > [java] com.uwyn.rife.database.exceptions.ExecutionErrorException:
> > Error while executing the SQL 'INSERT INTO account (birthdate,
> > country, created, email, firstname, lastname, location, sex, userId,
> > visibility) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'.
> > [java] at
> > com.uwyn.rife.database.DbPreparedStatement.executeUpdate
> > (DbPreparedStatement.java:236)
> > [java] at
> > com.uwyn.rife.database.querymanagers.generic.databasedrivers.org_apach
> > e_derby_jdbc_EmbeddedDriver$1.performUpdate
> > (org_apache_derby_jdbc_EmbeddedDriver.java:106)
> > [java] at
> > com.uwyn.rife.database.DbQueryManager.executeUpdate
> > (DbQueryManager.java:259)
> > [java] at
> > com.uwyn.rife.database.querymanagers.generic.databasedrivers.org_apach
> > e_derby_jdbc_EmbeddedDriver._insertWithoutCallbacks
> > (org_apache_derby_jdbc_EmbeddedDriver.java:91)
> > [java] at
> > com.uwyn.rife.database.querymanagers.generic.AbstractGenericQueryManag
> > er$3.useTransaction(AbstractGenericQueryManager.java:470)
> > [java] at
> > com.uwyn.rife.database.querymanagers.generic.AbstractGenericQueryManag
> > er$3.useTransaction(AbstractGenericQueryManager.java:381)
> > [java] at
> > com.uwyn.rife.database.DbQueryManager.inTransaction
> > (DbQueryManager.java:2783)
> > [java] at
> > com.uwyn.rife.database.querymanagers.generic.AbstractGenericQueryManag
> > er._save(AbstractGenericQueryManager.java:380)
> > [java] at
> > com.uwyn.rife.database.querymanagers.generic.databasedrivers.generic.s
> > ave(generic.java:117)
> > [java] at friends.test.TestsBase.createAccounts
> > (TestsBase.java:125)
> > [java] at friends.test.TestsBase.setup(TestsBase.java:90)
> > [java] at sun.reflect.NativeMethodAccessorImpl.invoke0
> > (Native Method)
> > [java] at
> > sun.reflect.NativeMethodAccessorImpl.invoke
> > (NativeMethodAccessorImpl.java:39)
> > [java] at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke
> > (DelegatingMethodAccessorImpl.java:25)
> > [java] at java.lang.reflect.Method.invoke(Method.java:585)
> > [java] at
> > org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:352)
> > [java] at
> > org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:
> > 282)
> > [java] at
> > org.testng.internal.Invoker.invokeConfigurations(Invoker.java:151)
> > [java] at org.testng.internal.Invoker.invokeMethod
> > (Invoker.java:316)
> > [java] at
> > org.testng.internal.Invoker.invokeTestMethods(Invoker.java:509)
> > [java] at
> > org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:90)
> > [java] at org.testng.TestRunner.privateRun(TestRunner.java:
> > 620)
> > [java] at org.testng.TestRunner.run(TestRunner.java:503)
> > [java] at org.testng.SuiteRunner.privateRun
> > (SuiteRunner.java:200)
> > [java] at org.testng.SuiteRunner.run(SuiteRunner.java:126)
> > [java] at org.testng.TestNG.run(TestNG.java:285)
> > [java] at org.testng.TestNG.privateMain(TestNG.java:372)
> > [java] at org.testng.TestNG.main(TestNG.java:321)
> > [java] at sun.reflect.NativeMethodAccessorImpl.invoke0
> > (Native Method)
> > [java] at
> > sun.reflect.NativeMethodAccessorImpl.invoke
> > (NativeMethodAccessorImpl.java:39)
> > [java] at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke
> > (DelegatingMethodAccessorImpl.java:25)
> > [java] at java.lang.reflect.Method.invoke(Method.java:585)
> > [java] at
> > com.uwyn.rife.test.RunWithEngineClassLoader.main
> > (RunWithEngineClassLoader.java:44)
> > [java] Caused by: SQL Exception: The check constraint
> > 'SQL051127032913372' was violated while performing an INSERT or UPDATE
> > on table 'APP.ACCOUNT'.
> > [java] at
> > org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> > [java] at
> > org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(
> > Unknown
> > Source)
> > [java] at
> > org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException
> > (Unknown
> > Source)
> > [java] at
> > org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
> > Source)
> > [java] at
> > org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
> > Source)
> > [java] at
> > org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown
> > Source)
> > [java] at
> > org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement
> > (Unknown
> > Source)
> > [java] at
> > org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate
> > (Unknown
> > Source)
> > [java] at
> > com.uwyn.rife.database.DbPreparedStatement.executeUpdate
> > (DbPreparedStatement.java:228)
> > [java] ... 32 more
> > [java] [Invoker 25300442] Invoking
> > friends.test.AccountTests.testAccounts
> > _______________________________________________
> > Rife-users mailing list
> > [email protected]
> > http://www.uwyn.com/mailman/listinfo/rife-users
> >
>
> --
> Geert Bevin Uwyn bvba
> "Use what you need" Avenue de Scailmont 34
> http://www.uwyn.com 7170 Manage, Belgium
> gbevin[remove] at uwyn dot com Tel +32 64 84 80 03
>
> PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
> Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
>
>
> _______________________________________________
> Rife-users mailing list
> [email protected]
> http://www.uwyn.com/mailman/listinfo/rife-users
>
_______________________________________________
Rife-users mailing list
[email protected]
http://www.uwyn.com/mailman/listinfo/rife-users