Podcast – Michael Mahemoff: Herding Code

  • Hello. What is Player FM?
    • (00:48) K Scott asks Mike for a quick introduction. Mike has studies both psychology and software engineering and has worked on a variety of applications, focusing lately on HTML5 web applications. He’s been working for the past few years on Player FM, a cloud based podcast application which is focused on discovery and multi-device synchronization.
    • (01:55) K Scott asks about the technologies used to build Player FM. Mike talks about the advantages of moving feed fetching to the cloud, the web site (using a PJAX implementation which pushes markup rather than data and HTML5 history) and an API.
  • Player FM API
    • (04:33) K Scott asks more about the API. The server is running Ruby on Rails using controllers that supply different format based on the extension in URL. The API is publicly available for experimentation but isn’t officially supported. Mike’s set up using a spectrum of detail levels (none, id, medium and full) rather than allowing clients to select specific fields. This allows you to be efficient in your API requests for hierarchies but is still cachable. He’s created a framework to support that.
    • (09:10) Jon mentions some of the URLs he’s seeing in browsing the API for listeners who want to play along at home. He asks Mike about the balance of a self documenting API vs the full hypermedia smart client approach. Mike says he thinks the API needs to be pretty mature for that to work and points out some of the curated lists in the feed.
    • (11:33) K Scott asks if the curation is community based. Mike says that’s the eventual goal, but for now he’s doing that.
    • (12:23) K Scott asks about the difficulty in tracking when all the feeds have been last updated. Mike says that originally it was a simple loop using feedzilla. Now it’s using sidekick and the PubSubHubbub standard (using the superfeeder service and webhooks). The clients are still polling now, but he’s going to be updating the clients to use Google Cloud Messaging (on Android) and iCloud Messaging (on Apple) so the updates will be realtime from publisher to client.
  • Native clients for Android and iOS
    • (14:30) K Scott asks if Mike’s building native clients. Mike says the iOS client is still in development and the Android app is native. K Scott says he’s wanted to do some Android dev but it’s always seemed like the most difficult platform. Mike says that it’s gotten easier lately due to the new application services and gives an example of the Google Wear Services. Jon asks for some more info on the Google Wear integration and Mike explains how any media framework application automatically gets some support, and they’ve extended it to create a phone application to allow episode browsing on the watch.
    • (17:15) K Scott says he was surprised by Mike’s blog post about the demand for Chromecast support for audio applications and asks about the work required to build that support. Mike explains the API integration and says that the hardest part was complying with the look and feel guidelines.
  • Advanced podcast support with Podlove
    • (20:02) Jon asks if there are things that podcasts can add to enable podcast applications to give a better experience. Mike talks about emerging standards like Podlove which adds support for chapters, time based links, attributions and related feeds. Jon says he’s been including timestamps in the show notes for a while so that seems pretty easy to implement. Mike talks about how TimeJump and Podlove could allow for deep linking into content.
    • (22:18) K Scott asks what’s been frustrating in dealing with feeds. Mike talks about the difficulty in feed parsing and the differing standards and implementations. Jon says he’s always just used Feedburner. Mike likes Feedburner and appreciates the built-in support for PubSubHubbub and would like to see Google pay more attention to it.
  • Misc: Business plan, mobile web support and Google I/O
    • (24:24) K Scott asks if Player FM is Mike’s full time job. Mike says it is. They’re not monetizing it yet, but he’s building out a freemium service with advanced features like unlimited subscriptions and advanced syncing across devices.
    • (26:16) Jon asks if Mike has plans for a Windows Phone application. Mike says he’d love to support it eventually, but right now his support for other platforms is via the mobile optimized website and the Player FM feeds.
    • (27:06) K Scott asks about Mike’s experience in bringing Player FM to Google I/O. Mike talks about the experience – it was his 4th Google I/O, and he’s been both an attendee and speaker in the past, but this time he was too busy to attend.
  • User Experience
    • (28:43) K Scott asks how Mike’s psychology degree has helped him in software development. Mike talks about the applications in user interface design and machine learning. Jon asks about Mikes thesis about human computer interaction; Mike talks about user interface design patterns for consistency.
    • (32:20) K Scott says he’s happy the Player FM site doesn’t use the ubiquitous cheeseburger menu. Mike talks about some of the UI design features in the web application.
  • API Optimization
    • (33:19) K Scott asks about optimizations in the API. Mike talks about timestamps in the API responses so the mobile applications can keep aware of which channels have been updated and get the responses from edge servers.
    • (36:10) Jon asks about using JSON LD and E-Tags. Mike says he hasn’t needed that since he’s building the clients and they’re doing the same checking.
    • (37:39) Jon asks how Cloudflare has worked for Mike. Mike says it’s been great, but there were a few surprises like caching of error responses.
    • (38:40) K Scott asks if it’s possible to remove things from the cache. Mike explains some of the options. Jon talks about some of the difficulties in diagnosing content problems when you’ve got multiple levels of caching and Mike agrees that it’d be nice if there were some visibility via HTTP headers.
  • Search and Discovery
    • (40:48) Jon asks if Player FM has additional markup to light up in search results. Mike says they were one of the early sites to be included in the Google app indexing setup, which supports deep linking in Android applications.
    • (42:30) K Scott says he’s looking forward to the recommendation features and Mike describes some of the things they’re including.
    • (43:30) Mike talks about Player FM support for full text search using Elastic Search to allow for easier discovery.
    • (44:25) Kevin asks if transcripts could be included in the full text search. Mike talks about some of the standards support.
  • Wrap Up
    • (45:49) K Scott asks what Mike does when he’s not working on Player FM.
    • (46:47) K Scott asks Mike what’s coming up for him in the near future. Mike talks about some Player FM features he’s excited about working on like intelligent discovery, collaborative filtering, server-side play tracking, analytics and platform support including an desktop form factor that will work offline. The desktop application is based on an open source project they’re working on that will compile a Chrome application and cross-compile native applications for Windows, Apple and Linux (based on node webkit).
    • (48:20) K Scott asks for any last words; Mike says he’s happy for any questions atmike@playerfm.com.

Continuar lendo Podcast – Michael Mahemoff: Herding Code

Detached entity passed to persist: Como resolver

Se você já se deparou com esse erro, aqui está como proceder para resolver.

Segue um exemplo de configuração de entidade que reproduz o erro:

@Entity
public class Transaction {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne(cascade = {CascadeType.ALL},fetch= FetchType.EAGER)
    private Account fromAccount;
....

@Entity
public class Account {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @OneToMany(cascade = {CascadeType.ALL},fetch= FetchType.EAGER, mappedBy = "fromAccount")
    private Set<Transaction> transactions;
}

Ao tentar persistir um objeto transaction o seguinte erro ocorre:

Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: com.paulsanwald.Account
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:141) 

Os problemas que temos no trecho de código da entidade Transaction acima são:

1.  Precisamos acrescentar a anotação @JoinColumn à propriedade fromAccount, referenciando a chave primária da entidade Account (“id”)

2. É necessário incluir os getters e setters públicos da propriedade

Com essas alterações teríamos o seguinte resultado:

@Entity
public class Transaction {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne(cascade = {CascadeType.ALL},fetch= FetchTy
pe.EAGER)
    @JoinColumn(name = "accountId", referencedColumnName = "id")
    private Account fromAccount;

//Getters & Setters
....
}
@Entity
public class Account {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @OneToMany(cascade = {CascadeType.ALL},fetch= FetchType.EAGER, mappedBy = "fromAccount")
    private Set<Transaction> transactions;
}

E assim um objeto transaction poderá ser persistido corretamente.

Bom é isso, espero ter esclarecido um pouco sobre este assunto. Bons estudos!