When I started writing I said I was going to treat JDO and JPA equally in these posts, but I've just learned something so earth-shatteringly helpful that happens to be specific to JDO. What would you have me do? Should I withhold valuable information just because it doesn't have a corresponding representation in JPA? That hardly seems right. How about a compromise: I'm going to share the JDO nugget and I promise to make it up to the JPA users at some point in the future. Sound reasonable? We have a deal? Ok, good. Now hold on to your hats, here we go:
I've always written PersistenceCapable declarations like this:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Foo {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
// ...
}
Kinda verbose, right? It turns out that if you omit 'identityType' DataNucleus will still do the right thing so long as you've set your PrimaryKey up properly:
@PersistenceCapable
public class Foo {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
// ...
}
I just saved you 41 characters. Happy new year everyone!
Subscribe to:
Post Comments (Atom)
I personally would say that
ReplyDelete@Persistent
String name;
is too verbose, and that docs should mention that there is a default persistent flag for each java type, and basic things like String don't need that.
Just saved you 11 more characters :-P
We had this debate internally before launch and decided that it was simpler to recommend @Persistent on every field than to ask users to learn which types were persistent by default and which were not. Given the amount of confusion that the default fetch group caused before we expanded it to include all app engine native datastore types, I think we made the right call. In a perfect world everyone would have the time and inclination to read the GAE docs AND the DataNucleus docs before they started coding, but in practice I don't see it happening.
ReplyDeleteThese terms are used to describe the isolation of the primary and secondary windings or isolation between the two. A shielded transformer is designed with a metallic shield between the primary and secondary windings to attenuate transient noise. Properties in noida We specialize in Noida and Greater Noida in all sorts of real estate property. Our impeccable services and honest policy makes us the best to deal in real estate in & around Noida.
ReplyDeleteRamprastha SKYZ Gurgaon sector 37D on Dwarka Express Way is Latest residential Project in Gurgaon having option 1bhk/2bhk/3bhk apartment with study room. Contact Homeseek Realtors for Ramprastha city as SKYZ.
ReplyDeleteGurgaon property asAbw verona hills on NH 8 sector-76 gurgaon is 2bhk/3bhk apartment having all morden facility. Homeseek Realtors for best deal Abw Verona Hills .
ReplyDeleteGurgaon is booming sector in all real estate sectors. Prices rise high day by day..
ReplyDeleteThis is such a great web site and resource for all the things in life that are fun.60s Fashion
ReplyDeleteA veteran educator has compiled her most-requested homeschooling workshop material so that families can become more proficient in educating their kids.80s Clothing
ReplyDeleteGameMS: Online online game currency trading store.
ReplyDeleteThis is the best choice to buy Madden coins
We are experienced
We have a long operating history.
We are trustworthy.