zava
I'm new here

Create a Like filter with a Entity as param

Jump to solution

Hi,

what mean "Attribute articles of entity type refs isn't simple".

This is the SchemaException I got when I try to rub this code...

    Select select = sess.createSelect(content.getEntityType().getName());

    Identifier id = article.getIdentifier();

    Like filter = new Like("articles", id); // articles column are Entity Reference

    select.setConstraint(filter);

    EntityList entityList = sess.executeQuery(select);   

How can I use a Entity/Identifier as a Like param.

Best Regards,

Antonio

Labels (1)
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Peter_Jodeleit
Crownpeak employee
Crownpeak employee

Re: Create a Like filter with a Entity as param

Jump to solution

Should also work without the "toString()" call.

Peter

View solution in original post

0 Kudos
4 Replies
kohlbrecher
Crownpeak employee
Crownpeak employee

Re: Create a Like filter with a Entity as param

Jump to solution

Hi Antonio,

what you need is a simple value like int or String, not an object like an identifier.

This could work:

fillter=new Like("arcticles",(String)article.getValue("name"));

I don't know your Database but arcticles sounds like a list or an entity. I think you need something more like articles.name or so.

Here is a complete, working sample for the Mithras Example, I hope this can help you:

import de.espirit.firstspirit.access.store.IDProvider;

import de.espirit.firstspirit.access.store.Store;

import de.espirit.or.query.*;

import de.espirit.or.*;

productContent2Name = "products";

// showInfo

showInfo(String message) {

          JOptionPane.showMessageDialog(null, message, "Seitentitel", JOptionPane.INFORMATION_MESSAGE);

}

contentStore = context.getUserService().getStore(Store.Type.CONTENTSTORE, false);

productContent2 = contentStore.getContent2ByName(productContent2Name);

schema = productContent2.getSchema();

session = schema.getSession();

select = session.createSelect(productContent2.getEntityType().getName());

like = new Like("Name_DE", "Accum 1");

select.setConstraint(like);

entityList = session.executeQuery(select);

showInfo(entityList.size()+"");

Best regards

Jan

zava
I'm new here

Re: Create a Like filter with a Entity as param

Jump to solution

Hi Jan,

I found the FSs relation column,

Like filter = new Like("arti_fs_id", article.getValue("fs_id").toString() );

tx & regards

Antonio

0 Kudos
zava
I'm new here

Re: Create a Like filter with a Entity as param

Jump to solution

or like this...

    Like filter = new Like("articles.fs_id", entity.getValue("fs_id").toString() );

0 Kudos
Peter_Jodeleit
Crownpeak employee
Crownpeak employee

Re: Create a Like filter with a Entity as param

Jump to solution

Should also work without the "toString()" call.

Peter
0 Kudos