1.3. Programming with Kodo

1.3.1. How long will it take me to learn JPA?
1.3.2. How long will it take me to learn the JDO APIs?
1.3.3. What standard APIs do I need to be familiar with to use Kodo?
1.3.4. What is the fastest way to get going with Kodo?
1.3.5. Do you provide any example applications using Kodo?
1.3.6. How do I issue queries to the database using Kodo?
1.3.7. How much more programming do I need to do to use Kodo?
1.3.8. What advantages does Kodo have over other persistence APIs?
1.3.9. Can Kodo be used in conjunction with other applications that operate against the same database?
1.3.10. Does Kodo provide extensions to JPA?
1.3.11. Does Kodo provide extensions to the JDO API?
1.3.12. How do I avoid vendor lock-in when using Kodo?
1.3.13. Is the application that I write in Kodo portable to other JPA or JDO vendors?
1.3.14. How does Kodo interact with the data access/transfer pattern (DAO / DTO)?
1.3.15. How does Kodo affect the build process of my application?
1.3.16. What is bytecode enhancement?
1.3.17. How can I debug enhanced persistent classes?
1.3.18. Can I use Kodo without having to enhance my classes?
1.3.19. What is the differences between data caching and query caching?
1.3.20. When using the mappingtool to create a schema for me, why does Kodo create a column called NAME0 for a field called name?
1.3.1.

How long will it take me to learn JPA?

JPA is designed to be extremely simple. You can view the entire Java Persistence API at http://java.sun.com/javaee/5/docs/api/index.html.

1.3.2.

How long will it take me to learn the JDO APIs?

The JDO API is designed to be extremely simple. You can view the entire JDO API Javadoc.

1.3.3.

What standard APIs do I need to be familiar with to use Kodo?

Aside from the Java Persistence and JDO APIs, you do not need to have any expertise in any APIs aside from the basic standard ones that the Java core library provides.

1.3.4.

What is the fastest way to get going with Kodo?

The Kodo tutorial provides a good introduction to developing a small application. See Section 1.2, “Kodo JPA Tutorial”, Section 2.2, “Kodo JDO Tutorial”.

1.3.5.

Do you provide any example applications using Kodo?

Kodo ships with numerous sample applications that can be adapted for your needs. For an overview of the samples that come with the Kodo distribution, see Chapter 1, Kodo Sample Code.

1.3.6.

How do I issue queries to the database using Kodo?

JPA specifies a query language called JPQL, which allows queries to be written in an object-centric, SQL-like syntax. See Chapter 10, JPA Query. JPA also offers the ability to directly execute SQL queries against the database. See Chapter 11, SQL Queries.

JDO specifies a query language called JDOQL, which allows queries to be written in an object-centric, Java-like syntax. See Chapter 11, Query. JDO also offers the ability to directly execute SQL queries against the database. See Chapter 17, SQL Queries.

1.3.7.

How much more programming do I need to do to use Kodo?

One of the goals of Kodo's transparent persistence is to make the persistence code in your application as minimal and unintrusive as possible. Typically, you will only need to write in the transaction demarcation, object queries, and the addition of root objects to the database.

1.3.8.

What advantages does Kodo have over other persistence APIs?

Kodo is much less intrusive than other persistence APIs, in that your code does not need to be constantly "polluted" with additional code to do things like traversing relations. In addition, Kodo's bytecode enhancement allows performance and scalability advantages that cannot be matched by other reflection-based persistence architectures, such as declarative "fetch groups", automatic change detection, and transparent relation traversal.

1.3.9.

Can Kodo be used in conjunction with other applications that operate against the same database?

Yes. Kodo does not require that it have exclusive read or write access to your database. The only restriction is that some optimistic version strategies may need to be respected by other applications.

1.3.10.

Does Kodo provide extensions to JPA?

As well as providing complete support for the core Java Persistence API set, Kodo does provide extensions for some advanced operations. The Reference Guide details these extensions.

1.3.11.

Does Kodo provide extensions to the JDO API?

As well as providing complete support for the core JDO API, Kodo does provide API extensions for some advanced or JDBC-specific operations. The Reference Guide details these extensions.

1.3.12.

How do I avoid vendor lock-in when using Kodo?

To avoid tying your application to any particular vendor, you should avoid using any non-standard API extensions. This will ensure that you can write your application in a way that will run in exactly the same way with any spec-compliant software.

1.3.13.

Is the application that I write in Kodo portable to other JPA or JDO vendors?

Yes, provided that the vendor's implementation is truly compliant with the specification.

1.3.14.

How does Kodo interact with the data access/transfer pattern (DAO / DTO)?

While you can wrap Kodo in the DAO pattern, most users find it easier to use Kodo APIs directly. Kodo provides much of DAO's functionality in a standardized and easy to use API set.

1.3.15.

How does Kodo affect the build process of my application?

When using Java 5 or higher, Kodo does not require any changes to your build process. Under previous Java versions, or if you choose not to take advantage of Kodo's Java 5 runtime enhancement, you will have to run the Kodo enhancer after compiling your persistent classes. See Section 5.2, “Enhancement”.

1.3.16.

What is bytecode enhancement?

Bytecode enhancement involves changing your compiled classes to mediate access to all the fields that are marked as persistent. See Section 5.2, “Enhancement”.

1.3.17.

How can I debug enhanced persistent classes?

Enhanced classes retain their line number tables. This means that lines in stack traces will match those of your original Java source file. Furthermore, enhanced classes can be used by debuggers in exactly the same way as unenhanced classes.

1.3.18.

Can I use Kodo without having to enhance my classes?

Kodo does not require bytecode enhancement to function, although not using enhancement involves writing all your persistent classes to implement the kodo.enhance.PersistenceCapable interface. As well as removing some of the transparency of Kodo, it makes the process considerably more complex.

1.3.19.

What is the differences between data caching and query caching?

Data caching caches data from the database. Basically, it caches your persistent objects. Query caching caches the identifiers of query result objects. The next time you run the same query, Kodo uses the cached identifiers to look up the result objects from the data cache, rather than running a database query.

So, an example of where these are different are if you did a query for "salary > 100" and then a query for "salary > 1000", the second query would be run against the database (it couldn't use the prior cached query), but all of the retrieved objects would be in the data cache, so the data for them wouldn't need to be retrieved.

1.3.20.

When using the mappingtool to create a schema for me, why does Kodo create a column called NAME0 for a field called name?

When Kodo automatically generates a column name for a field, it ensures that the name fits within the limitations of your database. This means that a long field name might be truncated, and that fields whose names are database keywords (such as name) will have a 0 appended to the column name.

If the auto-generated column names bother you, you can always manually edit your mapping information to control exactly what your schema should look like, or plug in your own mapping defaults through the kodo.jdbc.MappingDefaults.

 

Skip navigation bar   Back to Top