Sorry that was maybe a bit cryptic, here's working code (from Cay 3.1.1) as
per your imaginary case:
class Company extends _Company
{
public List getEmployees()
{
ObjRelationship rel = (ObjRelationship) Cayenne.getObjEntity(
getObjectContext().newObject( Emloyee.class ) )
How about something like:
ObjRelationship rel = Cayenne.getObjEntity( employee ).getAnyRelationship(
company ).getReverseRelationship();
Jurgen
-Original Message-
From: Maik Musall
Sent: Monday, March 19, 2018 3:41 PM
To: user@cayenne.apache.org
Subject: Re: Fetching a to-many DbRe
If you filter on [apache-cayenne] then you can also hover over the
apache-cayenne tag (top right, just left of Ask Question).
A popup should appear with a subscribe link top right, it'll send you an
email to confirm .
Jurgen
-Original Message-
From: Alexei Grigoriev
Sent: Friday
Created JIRA CAY-2254
-Original Message-
From: Musall, Maik
Sent: Thursday, March 2, 2017 10:49 AM
To: user@cayenne.apache.org
Subject: Re: Validation and @PrePersist
Hi Jurgen,
> Am 02.03.2017 um 09:33 schrieb do...@xsinet.co.za:
>
> I agree with your reasoning. So then the orig
Hi Maik
I agree with your reasoning. So then the original description of how
lifecycle events should behave in 3.1 is conceptually better (i.e. that
PrePersist & PreUpdate occur before validation), and the historical
behaviour is then a bug ?
It would be good for this to be changed, unless
Hi All
We had a similar discussion Sept-Oct 2012 where it was noted that there was
a discrepancy between the docs and the implementation. That was with 3.1B
where the behaviour was the same as it is now, i.e. validation occurs before
PrePersist (but as noted by Michael the 3.1 docs incorrectly
Hi Hugi
For this kind of thing use @PostAdd instead.
Regards
Jurgen
-Original Message-
From: Hugi Thordarson
Sent: Wednesday, March 1, 2017 1:18 PM
To: user@cayenne.apache.org
Subject: Validation and @PrePersist
Hi all,
I have some logic in a Listener that uses @PrePersist to popula
Hi Kumar
You have to include all the fields required by FakeTableDummyPosition.class, so
your select field clause has to specify all these fields:
buyer_account
exch_tools_trade_num
external_trade_oid
port_num
Regards
Jurgen
From: Kumar
Sent: Friday, December 23, 2016 1:12 PM
To: user@cayenn
Hi Kumar
Glad it worked :-)
I don't have any knowledge of Hibernate so I cannot say.
Maybe someone else on the list can comment ?
Regards
Jurgen
-Original Message-
From: Kumar
Sent: Friday, December 23, 2016 8:12 AM
To: user@cayenne.apache.org
Subject: Re: How to define a raw sql in t
Hi Kumar
You could do the following:
1. Create a DBEntity in the Modeler say FAKE_TABLE_DUMMY_POSITION with all
the fields that appear in your SQLTemplate's select field clause.
2. Then create the ObjEntity in the Modeler for DummyPositionRecord based on
the FAKE_TABLE_DUMMY_POSITION.
Mark
Hi Lon
Here is my kludge/hack of how I handle the problem of when "fetching an
object that it’s relationships weren’t automatically refreshing".
It's based on Cayenne storing a fault object in the data map to indicate
that the relationship hasn't been fetched yet.
Note, that I don't think this
Hi Juan
You can use context.modifiedObjects() to get a list of objects that have
changed and then process each one, something like:
Map changeMap = new HashMap<>();
for ( CayenneDataObject dataObj : (List)
context.modifiedObjects() )
{
DataRow changes = context.currentSnapshot( dataObj
Hi Juan
With regards to your question: is there some way to get a diff of the
failed context and apply that to the new context ?
You could try the following:
1. Before context.commitChanges() do something like:
DataRow changes = context.currentSnapshot( this ).createDiff
(
context.getO
Hi yeah, sorry my bad
I was out of office and just replied from my faulty memory it seems.
Thanks Michael, sorry Frank
j
-Original Message-
From: Michael Gentry
Sent: Thursday, March 17, 2016 4:12 PM
To: Cayenne Users
Subject: Re: Tracking down a Runtime Relationship - Cayenne 3.1
H
Hi Frank
Cayenne logs the runtime relationships it generates when it loads the
model into memory.
So if you look in the log which it also sends to System.err and search
for "runtimeRelationship725" then you will be able to see which entity
it's associated with. At least then he'll have a clu
Hi Fredrik
It would appear from the exception that the procedure can't be found in the
database.
Are you sure that you have created the procedure in foodbase and that the
spelling is the same ?
Regards
Jurgen
-Original Message-
From: Fredrik Widengren
Sent: Tuesday, March 15, 2016
Change the line that throws the exception --> newItem.setContact(item);
to: newItem.setContact( getObjectContext().localObject( item ) );
-Original Message-
From: Andrew Willerding
Sent: Thursday, March 3, 2016 4:16 PM
To: user@cayenne.apache.org
Subject: Re: No object is registered i
Ah I see, so by explicitly setting null columns Cayenne ensures that
the local object is in sync with the DB row.
Thanks, that makes sense :-)
Jurgen
-Original Message-
From: Andrus Adamchik
Sent: Wednesday, February 24, 2016 10:16 AM
To: user@cayenne.apache.org
Subject: Re: in
Hi All
I've notice that when Cayenne 3.1 constructs a SQL insert statement, that it
includes all null valued columns as well.
Is there a way to prevent this from happening because in MS SQL it prevents
default column constraint values from being applied.
I've tried creating an entity without
I've just done something like this, along these lines:
private class ProcessImages extends Task
{
private int imageCount = 0;
private int listSize;
@Override
protected Void call() throws Exception
{
String sql =
SQLTemplate i
Hi Ari
Not sure if this is what you are looking for, but this is what I did once:
1. Create a dbEntity in the modeler that has all the columns you are
interested in from the various tables. (So this dbEntity is more like a view
as it doesn't represent a real table.)
2. Create a read only Obj
1) If I have several parameters specified in the SQL and I don't provide
values for each in the map I pass in what happens to those values?
Bad idea. Raw SQL is not like Expressions where you can omit parameters.
A "bare" parameter will remain unparsed in the SQL and will be passed to
the DB a
Hi Johannes
Although this functionality isn't built into Cayenne there is a possible way
to do it.
I must first say though that I've not done this myself yet, and so this is
merely theory from my side.
Cayenne uses templates to generate the classes, so the idea is to modify the
template so t
Thanks for the pointers Andrus.
Jurgen
-Original Message-
From: Andrus Adamchik
Sent: Monday, August 18, 2014 10:18 PM
To: user@cayenne.apache.org
Subject: Re: Remote Change Notifications
It’s been a while since I used it, so I may have the details wrong, but..
DataContext fires an
Thanks Andrus
Say now I want to update my GUI when a change occurs, how do I know that an
object has been updated ?
regards
Jurgen
-Original Message-
From: Andrus Adamchik
Sent: Monday, August 18, 2014 1:52 PM
To: user@cayenne.apache.org
Subject: Re: Remote Change Notifications
Wh
Hi All
If you have “Remote Change Notifications” enabled (using JavaGroups, JMS,
etc.), how does Cayenne let you know when a change has been received ?
Or how does one listen for these changes / notifications ?
Thanks, regards
Jurgen
Hi Tony
I don't think you can get this type of result through the usual
relationships on Object Entities.
So you'll have to do it using a custom query, like so:
String sqlString = "select * from A where B_ID in (select B_ID from C "+
"where (type='$type1' and quantity='$qty1') or (type='$type
I've had a look at the DBCPDataSourceFactory source which is part of Cayenne
and think that a Password Encoder can easily be accommodated.
Don't know about JNDI.
Regards
Jurgen
-Original Message-
From: Michael Gentry
Sent: Thursday, March 13, 2014 5:33 PM
To: Cayenne Users
Subject: R
Yes thanks Michael,
but unfortunately the Password Encoder tab becomes disabled when you select
DBCPDataSourceFactory.
Created a RFE in Jira for this: CAY-1910
Regards
Jurgen
-Original Message-
From: Michael Gentry
Sent: Thursday, March 13, 2014 4:19 PM
To: Cayenne Users
Subject:
Ok, have created Jira ...
https://issues.apache.org/jira/browse/CAY-1909
Thanks Andrus
-Original Message-
From: Andrus Adamchik
Sent: Thursday, March 13, 2014 9:17 AM
To: user@cayenne.apache.org
Subject: Re: DBCPDataSourceFactory
On Mar 13, 2014, at 9:49 AM, do...@xsinet.co.za wrote:
I agree Andrus, however I'm not comfortable with having a username &
password in a properties file unless encrypted.
Now the XMLPoolingDataSourceFactory in the Modeler caters for a password
encoder, which is great.
However the database I'm using has a default transaction isolation level of
REA
Yip, that's what I was using in the Modeler but the username and pass have
to be in a properties file and I was hoping that there was a simple
alternative.
Anyway I've downloaded the Cayenne source and will extend either
DBCPDataSourceFactory or XMLPoolingDataSourceFactory.
Thanks again, r
Thanks again Mike
I don't manually configure or bind the DataSourceFactory to the
serverRuntime, but instead allow it to pull it in from the cayenne.xml
file.
Ok, you mentioned this before and I see in the Modeler where this can be
specified.
I take it then that MyDataSourceFactory just nee
Thanks Mike
Do I setup the BasicDataSource in the module I pass to ServerRuntime ?
I've got:
String iniFile = .;
MyDataSourceModule module = new MyDataSourceModule(iniFile);
server = new ServerRuntime( "cayenne-Vision.xml", module );
Do I then in MyDataS
Hi All
I've successfully configured and used DBCP as a Data Source Factory :-)
Does anybody know how to provide the username and password besides through
the properties file ?
Thanks,
Jurgen
Hi Mike
Thanks for your input, I had a look and found that I can specify a
DBCPDataSourceFactory in the modeler.
Found some info on that here
http://cayenne.apache.org/docs/3.0/dbcpdatasourcefactory.html
In short DBCPDataSourceFactory uses a properties file specified in the
modeler that can
Thanks Laurent
I understand the MyPoolManager class but I'm not sure about how to use it as
you demonstrated.
I am using 3.1 though and have a static method:
public static DataContext getContext()
{
if ( server == null )
{
String iniFile = .;
MyD
Hi All
I'm using jTDS to connect to a MS SQL db, their default setting for
transaction isolation is READ_COMMITED which I would like to change.
jTDS doesn't seem to have a property that can be sent via the connection
URL so that means that I need to change it through Cayenne.
So can anyone show
Hi Andrus
Thanks, I have done something like that:
I created an ObjEntity called ImageMeta without the BLOB field, and then
another ObjEntity called ImageBlob with just the BLOB field.
I then added a method to ImageMeta that retrieves ImageBlob when required.
This pattern works great for sel
Thanks for asking Andrus:
Because ClassTwo contains a BLOB that I don't want retrieved when asking for
ClassOne objects.
Jurgen
-Original Message-
From: Andrus Adamchik
Sent: Friday, December 20, 2013 8:58 AM
To: user@cayenne.apache.org
Subject: Re: Inheritance Question
No.
But a
Thanks for your reply Andrus.
I don't suppose that there is a way to tell Cayenne not to be so eager in
this case ?
Jurgen
-Original Message-
From: Andrus Adamchik
Sent: Friday, December 20, 2013 8:27 AM
To: user@cayenne.apache.org
Subject: Re: Inheritance Question
From what I can
Hi All
I have a dbEntity say ClassOne (its lightweight) and another that inherits
from it as ClassTwo (its heavyweight).
Now in my case I have a prefetch that retrieves ClassOne objects.
The problem that I have is that Cayenne is fetching ClassTwo data as well ?!
Surely Cayenne should only b
With regards to:
> I wonder if we should just deprecate distinct as a solution.
What about making it a no op ? With the Java doc explaining that it does
nothing because "Cayenne forces DISTINCT in the generated SQL whether you
specify it or not because it detects a match on to-many relationshi
Hi Ari
Thanks for the reply. My model is setup to return a Map for the
relationship as per your steps, and that works great.
My problems are:
1. How do I tell Cayenne to refetch the data for that relationship (when
parent object's cache strategy is set to SHARED_CACHE) ?
And/or 2. What is the A
Hi
1. I have an ObjEntity with a relationship that returns a Map, which I
need to refetch.
public Map getResults() {
return (Map)readProperty(RESULTS_PROPERTY);
}
How do I go about it ?
2. With a regular relationship that returns a list I used
RelationshipQuery like so:
public List getA
I also tried using a List instead of the Map and got the same result.
After rearranging things a bit I have found that selecting "To Many" on
the dbEntity backing the child class (ActivityResults) produces the
exception.
While switching "To Many" off removes the exception and commits succesfully.
Hi All
I need some help in resolving an error using Cayenne v.3.1B2 Feb 07 2013
18:36:43
I have an entity called Activity with a M-N relationship to ActivityResults.
The relationship getResults() returns a MAP.
New Activities with related ActivityResults commit (and updates in the
same session)
It would seem that it only fails when using camelCase then, as all my PK
identifiers are in Uppercase (in the DB, in my Cayenne model and in the
SQLTemplate query).
Sorry about the misinformation then in my previous post.
regards
Jurgen
> Andrus,
>
> the weird thing is that, even if the SQL que
Hi Giulio,
I've had this problem before. Try the following: goto SaleSummary in
Cayenne Modeler and click on the attributes tab.
Make sure that your SQLTemplate query contains all the DbAttributes listed.
They must be spelt exactly the same way (CaPs SenSitiTive), order isn't
important.
Also the
Hi Robert
>>> The primary key attributes are not displayed in the ObjEntity. Why
>>> not? It is displayed in the [DbEntity?]
>>
>> By default Cayenne hides the primary key from the user. Typically this
>> is what you want but you can easily expose it.
>
> How?
1. Select the ObjEntity,
2. Select
A method that I have used as a 4th option:
4. Have one database table, however the Cayenne class doesn't include the
BLOB field as an object attribute but as a relationship attribute. So
you'll need a 2nd Cayenne class to hold the BLOB field.
So the Cayenne DbEntity has a 1:1 relationship with i
I'm completely unfamiliar with Maven and SVN :-( but I gave it a shot.
Downloaded the SVN sources with Eclipse's import function and downloaded
Maven.
Got Maven running with "mvn clean install" in the Cayenne project folder.
The build often fails while testing cayenne-jdk1.5-unpublished but not
Over the weekend I tried running my app with jdk1.8 ea and found that some
of the methods (in the auto package classes) that return a sql.Date then
throw a class cast exception complaining that it can't cast util.Date to
sql.Date !?
However the app works fine in jdk1.7 ?
It appears that the diffe
Thanks everyone, its great.
>
> On Nov 8, 2012, at 1:18 PM, Aristedes Maniatis
> wrote:
>
>> What does that mean to you, the user of Cayenne? Well, not too much.
>> However if you see any missing images or broken links, or anything else,
>> please let us know and we'll get them fixed.
>
> It also
Hi
How can one find out through the API if a CayenneDataObject property
(field/column) is Mandatory or not ?
Currently using 3.1B1 i'm doing something like the following:
attribMap = Cayenne.getObjEntity( dbDataObj ).getAttributeMap();
attribMap.get( fieldPropertyName ).isMandatory();
Is this t
Thanks Andrus & Ramiro
Setting default values in the onPostAdd callback makes sense.
What about mandatory fields without default values ?
I suppose one could put in a dummy value in onPostAdd to circumvent the
validation execption.
But would this be good practice as this would prevent a validat
Does anybody have any news on this, please ?
Thanks.
Original Message
Subject: Re: 3.1B1 Validation Exception
Date:Thu, September 20, 2012 11:27
--
Not sure how to
Not sure how to submit the example, but here goes:
1. TestMap.map.xml
http://cayenne.apache.org/schema/3.0/modelMap";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
http://cayenne.apache.org/schema/3.0/m
Is this a bug or am I doing something wrong ?
I'm using 3.1B1 and getting a validation exception BEFORE my onPrePersist
lifecycle method is called ?
Caused by: org.apache.cayenne.validation.ValidationException: [v.3.1B1 May
28 2012
20:59:56]org.apache.cayenne.access.ObjectStoreGraphDiff.validateA
I'm using 3.1B1 and getting a validation exception BEFORE my onPrePersist
lifecycle method is called ?
Caused by: org.apache.cayenne.validation.ValidationException: [v.3.1B1 May
28 2012
20:59:56]org.apache.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(ObjectStoreGraphDiff.java:111)
Thanks Andrus and John
> I think you have to expose C. I believe "unmapped" means not defined in
> modeler, like if you add some instance variables that are not persisted.
>
> John
>
> On Wed, Sep 12, 2012 at 6:56 AM, wrote:
>
>> Hi
>>
>> The API says that readNestedProperty supports both mappe
Hi
The API says that readNestedProperty supports both mapped and unmapped
properties. I assume this means one can ask for eg: "db:SOME_FIELD".
Is there a way to set/write to an unmapped property ?
For eg. if I have a table with fields: A, B and C
And I only want A and B visible in my object ent
Ah :-) I figured it out ... didn't know that one could 'flatten' class
field attributes as well:
Highlight the attribute in the class definition and click on the [I] icon
(Edit Attribute). Then select the desired path.
Neat !
Thanks, great stuff.
> Thanks Ari, that works great.
>
> Say now t
Thanks Ari, that works great.
Say now the Paintings table or Hobbies table has a field eg: Notes
that i'm interested in. Then flattening won't work i suppose ?
How would you prefetch then, if no prefetching is done on the original
Artist or Person query ?
Thanks.
> On 6/09/12 8:54pm, do...@xsi
If for example i have the following classes: Person, Hobbies and Hobby
Hobbies has fields: personId and hobbyId
If no prefetching is done on the original Person query, is there a way to
prefetch Hobby when calling getHobbies() on Person ?
Thanks.
I have an Activity table and associated class containing a sql.Date field.
I also have a Results table (also with a date field) and associated
ActivityResults class.
At this point the model works without error.
However when i create a 1-M relationship, using Cayenne modeler, in
Activity to Activ
66 matches
Mail list logo