Re: "Can't get primary key from temporary id" :(

2009-04-23 Thread Joseph Schmidt
No if one is doing with DB directly or with JDBC, the following will work: -- start transaction INSERT INTO t_1 (name) VALUES ('name1'); INSERT INTO t_1 (name) VALUES ('name2'); INSERT INTO t_2 (name,t_1_id) select 'name1' , t_1.id from t_1 where t_1.name='name1'; commit; -- end transaction

Re: "Can't get primary key from temporary id" :(

2009-04-22 Thread Joseph Schmidt
You might also take a look at the 3.0 lifecycles that Ari mentioned in the issue, but my guess is that JPA lifecycles won't do what is needed. I did. To be inside the same transaction for writing, PrePersist would be the logical choice (from what I understood the docs). The very short document

Re: "Can't get primary key from temporary id" :(

2009-04-22 Thread Joseph Schmidt
I'd be interested in hearing what others have to say... feasible given the current cayenne stack? The problem is that the original poster is trying to use Cayenne like he uses pure SQL and No, I'm not. Like I mentioned in earlier posts, I'm using ObjRelationships and all the Cayenne goodie

Re: "Can't get primary key from temporary id" :(

2009-04-21 Thread Joseph Schmidt
Hm. You're defining a relationship; I've always mapped relationships aas relationships, and let Cayenne deal with the id specifics. Note that cayenne won't force the creation foreign key (although you should create one, if your db supports it). You say you have "too many tables like that"...

Re: "Can't get primary key from temporary id" :(

2009-04-20 Thread Joseph Schmidt
* write the record to database, fetch it back again and then you'll have the primary key Than this is not the same transaction :(. Correct. This is a limitation of how databases work, not Cayenne. You can't have a primary key until you write the record, unless you do something tricky like u

Re: Can't delete in Cayenne 3M5 :(

2009-04-08 Thread Joseph Schmidt
Hi, Thank you very much for the quick response. > The 3.0 API was relaxed from 2.0. In 2.0, deleteObject took > an org.apache.cayenne.Persistent.  In 3.0, it takes any > java.lang.Object. I see... > See: > http://cayenne.apache.org/doc/api/org/apache/cayenne/access/DataContext.html#deleteObje

Can't delete in Cayenne 3M5 :(

2009-04-08 Thread Joseph Schmidt
Trying to delete object entities with Cayenne 3M5 doesn't seem to work anymore - it used to work with 2.0 :(. I'm getting the error message: java.lang.NoSuchMethodError: org.apache.cayenne.access.DataContext.deleteObject(Lorg/apache/cayenne/Persistent;)V Is there something different in 3.0 abo

Re: "Can't get primary key from temporary id" :(

2009-04-08 Thread Joseph Schmidt
> It sounds like you are trying to > write a record into a log/audit > table.  Yes, for some entities it is some sort of high level audit, and for others it is a recent activity table. > Have you looked at MySQL triggers to do > this?  The advantage > of using a trigger is that even if someone c

Re: "Can't get primary key from temporary id" :(

2009-04-07 Thread Joseph Schmidt
> > Can't get primary key from temporary id > > > > > > while trying to access the 'id' of a newly created > object entity A. > > I need this 'id' to write the value together with some > > other fields in some other object entity B inside the same > > transaction. Between A and B the

"Can't get primary key from temporary id" :(

2009-04-07 Thread Joseph Schmidt
I'm getting the following error: Can't get primary key from temporary id while trying to access the 'id' of a newly created object entity A. I need this 'id' to write the value together with some other fields in some other object entity B inside the same transaction. Be

Re: Conditional relationship mapping?

2009-04-02 Thread Joseph Schmidt
> > This would sound cool to me too, but from the Cayenne > documentation example, this approach seems to have the > problem that Java has single inheritance :(. > > > > If there's only one such table than it would work > (single inheritance). > > E.g. In the above example, by doing a superclass

Re: What 3rd party jars are a must?

2009-04-02 Thread Joseph Schmidt
> > http://cayenne.apache.org/doc/jar-files-and-dependencies.html > > describes some of them but not all :(. > > > > What about?: > > asm-3.0..jar > > asm-commons-3.0.jar > > geronimo-jpa_3.0_spec-1.0.jar  ? > > > > Are they required when using a "pure cayenne" server, > i.e. no JPA? > > (they w

What 3rd party jars are a must?

2009-04-01 Thread Joseph Schmidt
The "lib/third-party" contains several jar files required as dependency. http://cayenne.apache.org/doc/jar-files-and-dependencies.html describes some of them but not all :(. What about?: asm-3.0.jar asm-commons-3.0.jar geronimo-jpa_3.0_spec-1.0.jar ? Are they required when using a "pure caye

Re: Conditional relationship mapping?

2009-03-31 Thread Joseph Schmidt
Thank you very much for your reply. > > Is it possible for Cayenne(and the Modeler) to map > conditional relationships? > > > > I have a table, e.g. "tag" that relates to too many > other tables, but one row is always related only to one > table. This is done by having > > instead of many foreign

Re: Conditional relationship mapping?

2009-03-31 Thread Joseph Schmidt
> Is it possible for Cayenne(and the Modeler) to map > conditional relationships? > > I have a table, e.g. "tag" that relates to too many other > tables, but one row is always related only to one table. > This is done by having > instead of many foreign keys columns, just with 2 in a > generic wa

Conditional relationship mapping?

2009-03-28 Thread Joseph Schmidt
Is it possible for Cayenne(and the Modeler) to map conditional relationships? I have a table, e.g. "tag" that relates to too many other tables, but one row is always related only to one table. This is done by having instead of many foreign keys columns, just with 2 in a generic way: - 'related_t

Re: Does Cayenne require a reversed relationship?

2009-03-28 Thread Joseph Schmidt
Sorry, but I'm a confused now :). > It used to be true and now it is no true anymore? Or is this so jut for Cayenne3? > that the reverse > db relationship was required, but > the reverse obj relationship was not required.  From > the application's > point of view, it doesn't have to be there. I'

Does Cayenne require a reversed relationship?

2009-03-28 Thread Joseph Schmidt
Does Cayenne require the use of a reversed relationship always? Of course they're practical, but in many schemes e.g. in the case of the 'user' table, just too many other tables (~2/3 of them) point to it because of the required "updated_by_user_id". If reversed relationships would be required

Re: Relationships without FK constraints?

2009-03-28 Thread Joseph Schmidt
> "Convention over Configuration" can be useful (and fast) in > simple implementations (ex: JSP form assignments) but may > still be a bit too "fuzzy" for the larger scaleable > projects. > > These are my current opinions.  I am interested in how > others look at it. The main issue is however tha

Re: Relationships without FK constraints?

2009-03-27 Thread Joseph Schmidt
> I am curious: how are your > related-tables managed in a relational database without > FK's? Is there no RDB perspective in the design? The ORM does it. e.g. ActiveRecord for Ruby on Rails applications, or other ORMs/stacks that work on similar concepts (and there are quite many lately). If I

Re: Relationships without FK constraints?

2009-03-27 Thread Joseph Schmidt
> Just reread your question.. Sorry for > misleading. This is true, Cayenne > cannot know about relationships in DB without FKs. So you > have to map them > manually Adding manually is not efficient for most cases (too big databases) :(. (This would not convince users to ditch RoR's ActiveRecord f

Re: Relationships without FK constraints?

2009-03-27 Thread Joseph Schmidt
> I don't reverse engineer often, but I > believe if the constraints > aren't defined in the DB, then the reverse engineering > process has no > way of knowing about the relationship, Well, it could, based on the naming conventions: e.g. "artist_id" from any table is a relation to "artists" table

Re: Relationships without FK constraints?

2009-03-27 Thread Joseph Schmidt
> I've used Cayenne with a DB that > didn't have FK constraints (the DB > basically only had PK uniqueness constraints).  Worked > fine.  Nice. Good to know :). > Just map > things correctly in the modeler. But the Cayenne Modeler doesn't recognize those relationships when reverse engineering t

Relationships without FK constraints?

2009-03-27 Thread Joseph Schmidt
Can Cayenne work (consistently) with relationships where the underlying foreign key constraint is missing? (e.g. when the fields for foreign key are there and respect the standard naming convention - artist_id for the relationship pointing to artists but the constraint is not set ? I tried to

Re: How to map/model files?

2009-03-21 Thread Joseph Schmidt
How to model/map files (with their content) e.g. in webapplications? What is the best practice? (1) To put their content as blob fully in the DB plus fields for properties, or (2) to put the metadata about files only in the DB and the content in a file system? or (3) other solution? The sec

Re: How to map/model files?

2009-03-21 Thread Joseph Schmidt
My preference (and it seems to be fairly efficient), is to continue with the standard design pattern of storing metadata (file-path, etc) in the database and storing the file in the filesystem. You can them make programatic references much easier. Thank you. I used too mostly this is the appro

How to map/model files?

2009-03-21 Thread Joseph Schmidt
How to model/map files (with their content) e.g. in webapplications? What is the best practice? (1) To put their content as blob fully in the DB plus fields for properties, or (2) to put the metadata about files only in the DB and the content in a file system? or (3) other solution? The secon