Hi Jeremy,

I tried out your code, I found this:
   addConstraint(new ConstrainedProperty("containerId")
     .notEmpty(true)
     .notNull(true)
     .manyToOne(RepositoryContainer.class, "id")

There's a problem with your notEmpty constraint. Since containerId is  
an integer, 'empty' means zero. So any time you set it to 0 it is  
validated as being MANDATORY. I couldn't find an INVALID validation  
error though. If I remove this constraint, everything works fine.

There's also another issue, you explicitly set the repository ID to  
0. Is that intended? By using the 'identifier' constraint without  
declaring the 'sparse' constraint will let RIFE use the native  
database method to generate IDs. Also, you might wanna remove the  
'unique' constraint on the id property if you're having them  
generated by the database, it is not necessary.

Some other minor remarks:

* in Home.java:

   DbQueryManager dbqm = new DbQueryManager(datasource);
   Select select = new Select(datasource);
   select
     .from(RepositoryContainer.class.getSimpleName())
     .where("id", "=", r.getContainerId());

Can be more easily written as:

   manager.getRestoreQuery(r.getContainerId());

Where manager is a GQM for the RepositoryContainer class.

Also, if you combine that with the next statement:

   RepositoryContainer rc2 = dbqm.executeFetchFirstBean(select,  
RepositoryContainer.class);

You can simply replace that by:

   RepositoryContainer rc2 = manager.getRestoreQuery(r.getContainerId 
());

This will generate exactly the same SQL statements, RIFE doesn't have  
a container that by itself manages entities.

* in SiteTest.java:

   new SiteBuilder("sites" +  File.separator + "main.xml").getSite();

Can be written as:

   new SiteBuilder("sites/main.xml").getSite();

This looks up a resource and not a file. Resources always use regular  
slashes as path separators, disregarding the platform you're using.

* in ApplicationInitializer.java:

You're swallowing the DatabaseException and not checking your return  
state. So if there's an error during installation, you never get  
notified about it. You will only not see a message being printed out  
that confirms the table creation. You'll still miss the details about  
what happened though.


Hope this helps,

Geert


On 17 Aug 2007, at 05:23, Jeremy Whitlock wrote:

> Geert,
>     I have attached a sample application that proves the problem I am
> having.  Included with this tar.gz is a README file that should tell
> you how to get Maven configured with the RIFE 1.6.1 jar and how to run
> it.  The source is so simple that viewing it should make a lot of
> sense.  Visiting the RIFE site as explained in the README should also
> give you some output to explain why I'm having this problem.  If you
> need anything else, please let me know.  Also, I hope I've just done
> something stupid.
>
> Take care,
>
> Jeremy
>
> On 8/15/07, Jeremy Whitlock <[EMAIL PROTECTED]> wrote:
>> Hi All,
>>     To make this as easy to diagnose as possible, I have decided to
>> post non-obfuscated code:
>>
>> SQL Trace Output
>> -------------------------
>> Aug 15, 2007 1:59:28 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : CREATE SEQUENCE SEQ_svnrepositorycontainer
>> Aug 15, 2007 1:59:28 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 103ms : CREATE TABLE svnrepositorycontainer (active CHAR(1) NOT
>> NULL, authzPath LONGVARCHAR NOT NULL, created TIMESTAMP NOT NULL,
>> description VARCHAR(256) NOT NULL, displayName VARCHAR(64) NOT NULL,
>> id INTEGER NOT NULL, path LONGVARCHAR NOT NULL, serverType VARCHAR(8)
>> NOT NULL, PRIMARY KEY (id), UNIQUE (id), CHECK (active != ''), CHECK
>> (authzPath != ''), CHECK (description != ''), CHECK (displayName !=
>> ''), CHECK (path != ''), CHECK (serverType != ''), CHECK (serverType
>> IN ('Apache','SvnServe')))
>> Aug 15, 2007 1:59:28 PM
>> org.thoughtspark.sac.elements.ApplicationInitializer$Deployer install
>> INFO: Table created for SVNRepositoryContainer
>> Aug 15, 2007 1:59:28 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : CREATE SEQUENCE SEQ_svnrepository
>> Aug 15, 2007 1:59:28 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 18ms : CREATE TABLE svnrepository (active CHAR(1) NOT NULL,
>> containerId INTEGER NOT NULL, created TIMESTAMP NOT NULL, dataStore
>> VARCHAR(4) NOT NULL, description VARCHAR(256) NOT NULL, displayName
>> VARCHAR(64) NOT NULL, id INTEGER NOT NULL, name VARCHAR(64) NOT NULL,
>> PRIMARY KEY (id), FOREIGN KEY (containerId) REFERENCES
>> svnrepositorycontainer (id), UNIQUE (id), CHECK (active != ''), CHECK
>> (containerId != 0), CHECK (dataStore != ''), CHECK (dataStore IN
>> ('BDB','FSFS')), CHECK (description != ''), CHECK (displayName !=  
>> ''),
>> CHECK (name != ''))
>> Aug 15, 2007 1:59:28 PM
>> org.thoughtspark.sac.elements.ApplicationInitializer$Deployer install
>> INFO: Table created for SVNRepository
>> Aug 15, 2007 2:00:06 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 20ms : SELECT * FROM SVNRepositoryContainer WHERE active = 'Y'
>> ORDER BY displayName ASC
>> Aug 15, 2007 2:00:53 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 7ms : SELECT count(*) FROM svnrepositorycontainer WHERE id = -1
>> Aug 15, 2007 2:00:53 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : SELECT count(*) FROM svnrepositorycontainer WHERE
>> displayName = 'Some Container' AND active = 'Y'
>> Aug 15, 2007 2:00:53 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : SELECT count(*) FROM svnrepositorycontainer WHERE path =
>> '/Some/path' AND active = 'Y'
>> Aug 15, 2007 2:00:53 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 1ms : CALL NEXT VALUE FOR SEQ_svnrepositorycontainer
>> Aug 15, 2007 2:00:53 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 112ms : INSERT INTO svnrepositorycontainer (active, authzPath,
>> created, description, displayName, id, path, serverType) VALUES  
>> (?, ?,
>> ?, ?, ?, ?, ?, ?)
>> Aug 15, 2007 2:00:54 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 1ms : SELECT * FROM SVNRepositoryContainer WHERE active = 'Y'
>> ORDER BY displayName ASC
>> Aug 15, 2007 2:01:00 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : SELECT * FROM SVNRepository WHERE active = 'Y' ORDER BY
>> displayName ASC
>> Aug 15, 2007 2:01:00 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : SELECT * FROM SVNRepositoryContainer WHERE active = 'Y'
>> ORDER BY displayName ASC
>> Container Id: 0
>> Aug 15, 2007 2:01:20 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : SELECT count(*) FROM svnrepository WHERE id = -1
>> Aug 15, 2007 2:01:20 PM com.uwyn.rife.database.DbStatement  
>> outputTrace
>> INFO: 0ms : SELECT * FROM svnrepositorycontainer WHERE id = 0
>>
>> SVNRepository.java
>> ----------------------------
>> .....
>> public class SVNRepository {
>>         private int id = -1;
>>         private int containerId;
>> .....
>>         /**
>>          * @return Returns the id.
>>          */
>>         public int getId() {
>>                 return id;
>>         }
>>         /**
>>          * @param id The id to set.
>>          */
>>         public void setId(int id) {
>>                 this.id = id;
>>         }
>>         /**
>>          * Returns the id of the repository container this  
>> repository is
>>          * associated with.
>>          */
>>         public int getContainerId() {
>>                 return containerId;
>>         }
>>
>>         /**
>>          * Sets the repository container id.
>>          *
>>          * @param The repository container id.
>>          */
>>         public void setContainerId(int containerId) {
>>                 this.containerId = containerId;
>>         }
>> .....
>>
>> SVNRepositoryContainer.java
>> -----------------------------------------
>> .....
>> public class SVNRepositoryContainer {
>>         private int id = -1;
>> .....
>>         /**
>>          * @return Returns the id.
>>          */
>>         public int getId() {
>>                 return id;
>>         }
>>         /**
>>          * @param id The id to set.
>>          */
>>         public void setId(int id) {
>>                 this.id = id;
>>         }
>> .....
>>
>> SVNRepositoryMetaData.java
>> -----------------------------------------
>> ....
>> public SVNRepositoryMetaData extends MetaData {
>> .....
>>                 addConstraint(new ConstrainedProperty("containerId")
>>                         .notEmpty(true)
>>                         .notNull(true)
>>                         .manyToOne(SVNRepositoryContainer.class,  
>> "id")
>>                 );
>> .....
>>
>> SVNRepositoriesAdd.java
>> ------------------------------------
>> .....
>> public SVNRepositoriesAdd extends Element {
>> .....
>>     public void processElement() throws EngineException {
>>         SVNRepository bean = getNamedInputBean("Repository");
>>
>>         if (((Validated)repository).validate 
>> (SACUtils.getGenericQueryManager(SVNRepository.class)))
>> {
>>             ....
>>         } else {
>>             ....
>> .....
>> .....
>>
>> The SQL trace above shows the following:
>>
>> Creation of the SVNREPOSITORYCONTAINER table
>> Creation of the SVNREPOSITORY table
>> Creation of necessary sequences
>> Creation of a row in the SVNREPOSITORYCONTAINER table with an id of 0
>> Attempt to create a row in the SVNREPOSITORY table with a  
>> CONTAINERID of 0
>>
>> The problem is that the validate() call is always returning INVALID.
>> Unfortunately, it makes no sense because there is a row in the
>> SVNREPOSITORYCONTAINER table with an id of 0.  I have verified  
>> this in
>> Java code and using a database browsing tool.  Hopefully with exact
>> code, this can be easier to diagnose.
>>
>> Take care,
>>
>> Jeremy
>>
>
> >
> <rife-many-to-one-example.tar.gz>

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"rife-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to