Hi!
The code at the end of this mail creates the following tables (for mysql), and 
the following error:

10:53:34,420  [Schema               main       DEBUG]  Check of existence of 
regulation_dependency returned no table
10:53:34,420  [Schema               main       DEBUG]  Creating table 
regulation_dependency
10:53:34,420  [Schema               main       DEBUG]  CREATE TABLE 
regulation_dependency
(
    regulationid LONG VARBINARY NOT NULL,
    dependentregulationid LONG VARBINARY NOT NULL,
    idx INTEGER NOT NULL,
    CONSTRAINT regulation_dependency_pk PRIMARY KEY (idx)
) ENGINE=INNODB
10:53:34,453  [Schema               main       DEBUG]  Execution Time = 33 ms
10:53:34,457  [Schema               main       DEBUG]  Creating candidate key 
"Regulation_description_must_be_unique" in catalog "" schema ""
10:53:34,457  [Schema               main       DEBUG]  ALTER TABLE regulation 
ADD CONSTRAINT regulation_description_must_be_unique UNIQUE 
(ownedby,regulationtitle)
10:53:34,510  [Schema               main       DEBUG]  Execution Time = 53 ms
10:53:34,520  [Schema               main       DEBUG]  Creating index 
"regulation_dependency_n49" in catalog "" schema ""
10:53:34,520  [Schema               main       DEBUG]  CREATE INDEX 
regulation_dependency_n49 ON regulation_dependency (regulationid)
10:53:34,525  [Schema               main       DEBUG]  Creating index 
"regulation_dependency_n50" in catalog "" schema ""
10:53:34,525  [Schema               main       DEBUG]  CREATE INDEX 
regulation_dependency_n50 ON regulation_dependency (dependentregulationid)
10:53:34,529  [Schema               main       DEBUG]  Creating foreign key 
constraint : "regulation_dependency_fk2" in catalog "" schema ""
10:53:34,529  [Schema               main       DEBUG]  ALTER TABLE 
regulation_dependency ADD CONSTRAINT regulation_dependency_fk2 FOREIGN KEY 
(dependentregulationid) REFERENCES regulation (id)
10:53:34,531  [Schema               main       DEBUG]  Creating foreign key 
constraint : "regulation_dependency_fk1" in catalog "" schema ""
10:53:34,531  [Schema               main       DEBUG]  ALTER TABLE 
regulation_dependency ADD CONSTRAINT regulation_dependency_fk1 FOREIGN KEY 
(regulationid) REFERENCES regulation (id)
10:53:34,534  [Datastore            main       ERROR]  An exception was thrown 
while adding/validating class(es) : BLOB/TEXT column 'regulationid' used in key 
specification without a key length
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: BLOB/TEXT column 
'regulationid' used in key specification without a key length
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


code:


    //region > Dependent Regulations (property), add (action), remove (action)
    // overrides the natural ordering
    public static class RegulationsComparator implements Comparator<Regulation> 
{
        @Override
        public int compare(Regulation p, Regulation q) {
            Ordering<Regulation> byRegulationTitle = new Ordering<Regulation>() 
{
                public int compare(final Regulation p, final Regulation q) {
                    return 
Ordering.natural().nullsFirst().compare(p.getRegulationTitle(), 
q.getRegulationTitle());
                }
            };
            return byRegulationTitle
                    .compound(Ordering.<Regulation>natural())
                    .compare(p, q);
        }
    }

   @javax.jdo.annotations.Persistent(table="regulation_dependency")
     @javax.jdo.annotations.Join(column="regulationId")
    @javax.jdo.annotations.Element(column="dependentRegulationId")
    private SortedSet<Regulation> dependentRegulations = new 
TreeSet<Regulation>();
    @MemberOrder(name="Regulation", sequence = "98")

       //@CollectionInteraction
    //@Collection(domainEvent=Regulation.Dependencies.class)
    
@CollectionLayout(sortedBy=RegulationsComparator.class,render=RenderType.EAGERLY)
    public SortedSet<Regulation> getDependentRegulations() {
        return dependentRegulations;
    }
    public void setDependentRegulations(final SortedSet<Regulation> 
dependentRegulations) {
        this.dependentRegulations = dependentRegulations;
    }
    public void addToDependentRegulations(final Regulation regulation) {
        getDependentRegulations().add(regulation);
    }
    public void removeFromDependentRegulations(final Regulation regulation) {
        getDependentRegulations().remove(regulation);
    }

// This is the add-Button!!!
  @MemberOrder(name="Dependent Regulations", sequence = "10")
  public Regulation add(final @ParameterLayout(typicalLength=20) Regulation 
regulation) {
       // By wrapping the call, Isis will detect that the collection is modified
       // and it will automatically send CollectionInteractionEvents to the 
Event Bus.
       // ToDoItemSubscriptions is a demo subscriber to this event
        
wrapperFactory.wrapSkipRules(this).addToDependentRegulations(regulation);
        return this;
    }

    public List<Regulation> autoComplete0Add(final @MinLength(2) String search) 
{
        final List<Regulation> list = regulations.autoComplete(search);
        list.removeAll(getDependentRegulations());
        list.remove(this);
        return list;
    }

    public String disableAdd(final Regulation regulation) {
               if(isFinalized()) {
            return "Cannot add dependencies for items that are Finalized";
        }
        return null;
    }
    // validate the provided argument prior to invoking action
    public String validateAdd(final Regulation regulation) {
               if(getDependentRegulations().contains(regulation)) {
            return "Already a dependency";
        }
        if(regulation == this) {
            return "Can't set up a dependency to self";
        }
        return null;
    }

    // This is the Remove-Button!!
    @MemberOrder(name="Dependent Regulations", sequence = "20")
    public Regulation remove(final @ParameterLayout(typicalLength=20) 
Regulation regulation) {
       // By wrapping the call, Isis will detect that the collection is modified
       // and it will automatically send a CollectionInteractionEvent to the 
Event Bus.
        // ToDoItemSubscriptions is a demo subscriber to this event
        
wrapperFactory.wrapSkipRules(this).removeFromDependentRegulations(regulation);
        return this;
    }
    // disable action dependent on state of object
    public String disableRemove(final Regulation regulation) {
        if(isFinalized()) {
            return "Cannot remove dependencies for items that are Finalized";
        }
        return getDependentRegulations().isEmpty()? "No dependencies to 
remove": null;
    }
    // validate the provided argument prior to invoking action
    public String validateRemove(final Regulation regulation) {
               if(!getDependentRegulations().contains(regulation)) {
            return "Not a dependency";
        }
        return null;
    }
    // provide a drop-down
    public Collection<Regulation> choices0Remove() {
               return getDependentRegulations();
    }
    //endregion Dependent Regulations


So the question is how I can set the type of the keys so that they are accepted?

Best,
Marianne.

Reply via email to